Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

Hive UDF --Class Not Found Error

Solved Go to solution

Hive UDF --Class Not Found Error

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

Accepted Solutions
Highlighted

Re: Hive UDF --Class Not Found Error

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
Highlighted

Re: Hive UDF --Class Not Found Error

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

Highlighted

Re: Hive UDF --Class Not Found Error

That worked! Thanks a lot Sir!

Highlighted

Re: Hive UDF --Class Not Found Error

You're welcome! :)

Don't have an account?
Coming from Hortonworks? Activate your account here