1
votes

Hi Friends I am new to Hive. I am trying to create one UDF in Hive called ConvertDateFormatUDF I am getting the following error while creating temporary function:

hive>add jar /home/cloudera/date.jar

Added /home/cloudera/date.jar to class path Added resource: /home/cloudera/date.jar

hive>CREATE TEMPORARY FUNCTION fun as 'com.db.acedq.opal.hive.ConvertDateFormatUDF';
java.lang.NoClassDefFoundError: org/apache/pig/EvalFunc
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
Caused by: java.lang.ClassNotFoundException: org.apache.pig.EvalFunc
FAILED: Execution Error, return code -101 from org.apache.hadoop.hive.ql.exec.FunctionTask

Please someone help me as i am new to hive. can someone tell me the steps to be followed

2

2 Answers

2
votes

Your hive UDF is somehow referring to a Pig class, which would be probably in the pig.jar file, which is not necessarily on the classpath in a Hive environment.

External jars can be added just like your own user-created jars using add jar. E.g.,

hive> add jar /usr/lib/pig/pig.jar;

I'm not sure what your UDF is trying to do, but "ConvertDateFormat" sounds like a pretty straightforward method, so if your code did not need to explicitly reference a pig class, I'd check it for bugs. You may have left in some boilerplate code copied from your pig UDFs maybe.

2
votes

Seems Like the java code of UDF you are creating is referring PIG libraries. While creating Hive UDF you should include hive library. I have mentioned whole Procedure in following link http://lets-do-something-big.blogspot.in/2014/02/hive-udf-example.html . Please let me know if you still face problem