Help Center/ MapReduce Service/ Troubleshooting/ Using Hive/ An Error Is Reported When UDF Is Created Using Beeline
Updated on 2022-09-14 GMT+08:00

An Error Is Reported When UDF Is Created Using Beeline

Symptom

Run the following command:

create function fn_test3 as 'test.MyUDF' using jar 'hdfs:///tmp/udf2/MyUDF.jar'

The following error is reported:

Error: Error while compiling statement: FAILED: HiveAccessControlException Permission denied: Principal [name=admin, type=USER] does not have following privileges for operation CREATEFUNCTION [[ADMIN PRIVILEGE] on Object [type=DATABASE, name=default], [ADMIN PRIVILEGE] on Object [type=FUNCTION, name=default.fn_test3]] (state=42000,code=40000)

Cause Analysis

To create a permanent function in Hive, role admin is required.

Solution

Run the set role admin command before running the statement.