Reply
New Contributor
Posts: 1
Registered: ‎06-06-2017
Accepted Solution

SemanticException Error retrieving udf

Hey,
We create the udf function in hive:

1) hdfs dfs -put /tmp/changeFormatDate-0.0.1.jar /data/changeFormatDate-0.0.1.jar

2) With Sentry enabled, grant privilege to the JAR on HDFS:

create role role_udfs;
GRANT ALL ON URI 'hdfs:///data/changeFormatDate-0.0.1.jar' TO ROLE role_udfs;
grant role role_udfs to group hive;


Detail in changeFormatDate-0.0.1.jar

META-INF/
META-INF/MANIFEST.MF
com/
com/ag2rlm/
com/ag2rlm/udfs/
com/ag2rlm/udfs/ChangeFormatDate.class
META-INF/maven/
META-INF/maven/com.ag2rlm/
META-INF/maven/com.ag2rlm/changeFormatDate/
META-INF/maven/com.ag2rlm/changeFormatDate/pom.xml
META-INF/maven/com.ag2rlm/changeFormatDate/pom.properties

Class heading
package com.ag2rlm.udfs;
.....
public class ChangeFormatDate extends UDF
.....

 

3) create function with hdfs
CREATE FUNCTION CHANGE_FORMAT_DATE AS 'com.ag2rlm.udfs.ChangeFormatDate';

output error :

Error while compiling statement: FAILED: SemanticException Error retrieving udf class:com.ag2rlm.udfs.ChangeFormatDate


Can you help me on this problem ?

Best regards,

Highlighted
Posts: 642
Topics: 3
Kudos: 105
Solutions: 67
Registered: ‎08-16-2016

Re: SemanticException Error retrieving udf

Can you run 'SHOW CURRENT ROLES;' and 'SHOW GRANT ROLE <role_name>;' and provide the output for the user creating the function?

Is /data, in HDFS, and /tmp, in the local filesystem, in the Hive Aux or Reloadable Aux paths? If yes, did you restart HS2 (if it is in the Aux path) or run the reload command in beeline (if it is in the Reloadable Aux path)?

You ran the grant statement on the HDFS path but not the local path. Refer to the UDF doc as it states that you must do both.

The create function statement is also missing the USING JAR portion. You need to specify the jar path in it.

https://www.cloudera.com/documentation/enterprise/5-8-x/topics/cm_mc_hive_udf.html
Announcements