Support Questions

Find answers, ask questions, and share your expertise

Hive UDF --Class Not Found Error

avatar

Hi Experts,

Can anyone please help me with below error?

I am writing a small code to understand how UDF works. The java code is as below:

package UDF;

import org.apache.hadoop.hive.ql.exec.UDF;
import org.apache.hadoop.io.Text;

@SuppressWarnings("deprecation")
public class MyUpper extends UDF{

public Text evaluate(final Text s){
if (s==null){return null;}
return new Text(s.toString().toUpperCase());
}
}
//Class path of above class is: /Hive/src/UDF/MyUpper.java
I have created a jar file for this class as test.jar and added the jar in hive.

hive> ADD JAR test.jar;
Added [test.jar] to class path
Added resources: [test.jar]
Now I am trying to create a temporary function upper by typecasting the java function MyUpper. Below is my command.

create temporary function upper as 'Hive/src/UDF/MyUpper.java';
or I have tried below command also.

create temporary function upper as 'Hive/src/UDF/MyUpper.java';
Both the commands above is giving me error as below:

FAILED: Class Hive.src.UDF.MyUpper.java not found
FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.FunctionTask
1 ACCEPTED SOLUTION

avatar

Hey @Abhijnan Kundu!
Did you tried to create like this?

CREATE TEMPORARY FUNCTION myupper as 'udf.myupper';

Hope this helps

View solution in original post

3 REPLIES 3

avatar

Hey @Abhijnan Kundu!
Did you tried to create like this?

CREATE TEMPORARY FUNCTION myupper as 'udf.myupper';

Hope this helps

avatar

That worked! Thanks a lot Sir!

avatar

You're welcome! 🙂