Registering the UDF

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:
  1. Log in to the Data Warehouse service and open Ranger from the Database Catalog associated with your Hive Virtual Warehouse.
  2. 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.

  3. 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.
  1. Open Hue from the Hive Virtual Warehouse in CDW.
  2. 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';
  3. 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.
  4. Verify whether the UDF is registered.
    SHOW FUNCTIONS;
    You scroll through the output and find default.typeof.