In Cloudera Data Warehouse (CDW), you run a command from Hue to make the UDF
functional in Hive queries. The UDF persists between HiveServer restarts.
You need to set up UDF access using a Ranger policy as follows:
- Log in to the Data Warehouse service and open Ranger from the Database Catalog
associated with your Hive Virtual Warehouse.
- On the Service Manager page, under the HADOOP
SQL section, select the Database Catalog associated with the
Hive Virtual Warehouse in which you want to run the UDFs.
The list of policies
is displayed.
- Select the
all - database, udf
policy and add the users needing
access to Hue. To add all users, you can specify
{USER}.
In this task, the registration command differs depending
on the method you choose to configure the cluster for finding the JAR. If you use the
Hive aux library directory method that involves a symbolic link, you need to restart the
HiveServer pod after registration. If you use the direct JAR reference method, you do
not need to restart HiveServer. You must recreate the symbolic link after any patch or
maintenance upgrades that deploy a new version of Hive.
-
Open Hue from the Hive Virtual Warehouse in CDW.
-
Run the registration command by including the JAR location in the command as
follows:
CREATE FUNCTION udftypeof AS 'com.mycompany.hiveudf.TypeOf01' USING JAR 'hdfs:///warehouse/tablespace/managed/TypeOf01-1.0-SNAPSHOT.jar';
- Optional:
Restart the HiveServer.
You can either delete the hiveserver2-0 pod using Kubernetes, or, you can edit
an HS2 related configuration, and CDP restarts the HiveServer pod.
-
Verify whether the UDF is registered.
You scroll through the output and find
default.typeof
.