In Cloudera Data Warehouse, you run a command from a client interface to
your Virtual Warehouse, such as Data Explorer, 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 Cloudera 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 Data Explorer. To add all users, you can specify
{USER}.
-
Open Data Explorer from the Hive Virtual Warehouse in Cloudera Data Warehouse .
-
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';
-
Restart the Virtual Warehouse.
-
Check that the UDF is registered.
You scroll through the output and find
default.typeof.
-
Run a query that calls the UDF.
SELECT students.name, udftypeof(students.name) AS type FROM students WHERE age=35;