Registering the UDF

In Cloudera Data Warehouse (CDW), you run a command from a client interface to your Virtual Warehouse, such as Hue, to call the UDF from 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.
  • Select the all - database, udf policy and add the users needing access to Hue. To add all users, you can specify {USER}.
  1. Open Hue from the Hive Virtual Warehouse in CDW.
  2. Run the registration command by including the JAR location on your object store.
    For example, on AWS:
    CREATE FUNCTION udftypeof AS 'com.mycompany.hiveudf.TypeOf01' USING JAR 's3a://mybucket/mypath/TypeOf01-1.0-SNAPSHOT.jar';
    On Azure:
    CREATE FUNCTION udftypeof AS 'com.mycompany.hiveudf.TypeOf01' USING JAR 'abfs://mybucket/mypath/TypeOf01-1.0-SNAPSHOT.jar';
  3. Restart the Virtual Warehouse.
  4. Check that the UDF is registered.
    SHOW FUNCTIONS;
    You scroll through the output and find default.typeof.
  5. Run a query that calls the UDF.
    SELECT students.name, udftypeof(students.name) AS type FROM students WHERE age=35;