hive-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rishabh Bhardwaj <rbnex...@yahoo.com>
Subject Re: HIVE UDF Error
Date Wed, 09 Apr 2014 06:42:28 GMT
Hi Nitin,
Thanks for the concern.
Here is the code of the UDF,
import org.apache.hadoop.hive.ql.exec.Description;
import org.apache.hadoop.hive.ql.exec.UDF;
import org.apache.hadoop.io.Text;


@Description(
  name="SimpleUDFExample",
  value="returns 'hello x', where x is whatever you give it (STRING)",
  extended="SELECT simpleudfexample('world') from foo limit 1;"
  )
class SimpleUDFExample extends UDF {
  
  public Text evaluate(Text input) {
    if(input == null) return null;
    return new Text("Hello " + input.toString());
  }
}
From google I came across a blog.

I have taken this from here (git link).

 
On Wednesday, 9 April 2014 12:08 PM, Nitin Pawar <nitinpawar432@gmail.com> wrote:
 
Can you put first few lines of your code here or upload code on github and share the link? 





On Wed, Apr 9, 2014 at 11:59 AM, Rishabh Bhardwaj <rbnext29@yahoo.com> wrote:

Hi all,
>I have done the following steps to create a UDF in hive but getting error.Please help
me.
>1. Created the udf as described here.
>2. Compiled it successfully.
>3. Copy the class file to a directory hiveudfs.
>4. Added it to a jar with this command: jar -cf hiveudfs.jar hiveudfs/SimpleUDFExample.class
>5. Import the jar into hive. add jar hiveudfs.jar;  (Added Successfully)
>
>create temporary function helloworld as 'hiveudfs.SimpleUDFExample';
>At this I am getting the following error,
>
>hive> create temporary function helloworld as 'hiveudfs.SimpleUDFExample';
>java.lang.NoClassDefFoundError: hiveudfs/SimpleUDFExample (wrong name: SimpleUDFExample)
>    at java.lang.ClassLoader.defineClass1(Native Method)
>    at java.lang.ClassLoader.defineClass(ClassLoader.java:791)
>    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
>    at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
>    at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
>    at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
>    at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
>    at
 java.security.AccessController.doPrivileged(Native Method)
>    at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
>    at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
>    at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
>    at java.lang.Class.forName0(Native Method)
>    at java.lang.Class.forName(Class.java:266)
>    at org.apache.hadoop.hive.ql.exec.FunctionTask.getUdfClass(FunctionTask.java:105)
>    at org.apache.hadoop.hive.ql.exec.FunctionTask.createFunction(FunctionTask.java:75)
>    at org.apache.hadoop.hive.ql.exec.FunctionTask.execute(FunctionTask.java:63)
>    at org.apache.hadoop.hive.ql.exec.Task.executeTask(Task.java:138)
>    at org.apache.hadoop.hive.ql.exec.TaskRunner.runSequential(TaskRunner.java:57)
>    at
 org.apache.hadoop.hive.ql.Driver.launchTask(Driver.java:1353)
>    at org.apache.hadoop.hive.ql.Driver.execute(Driver.java:1137)
>    at org.apache.hadoop.hive.ql.Driver.run(Driver.java:945)
>    at org.apache.hadoop.hive.ql.Driver.run(Driver.java:867)
>    at org.apache.hadoop.hive.cli.CliDriver.processLocalCmd(CliDriver.java:259)
>    at org.apache.hadoop.hive.cli.CliDriver.processCmd(CliDriver.java:216)
>    at org.apache.hadoop.hive.cli.CliDriver.processLine(CliDriver.java:412)
>    at org.apache.hadoop.hive.cli.CliDriver.run(CliDriver.java:755)
>    at org.apache.hadoop.hive.cli.CliDriver.main(CliDriver.java:613)
>    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>    at
 sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
>    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>    at java.lang.reflect.Method.invoke(Method.java:601)
>    at org.apache.hadoop.util.RunJar.main(RunJar.java:208)
>FAILED: Execution Error, return code -101 from org.apache.hadoop.hive.ql.exec.FunctionTask
>
>Thanks,
>Rishabh.
>


-- 
Nitin Pawar
Mime
View raw message