in your code and that code package is missing

what you need to do is
define package something like

package org.apache.hadoop.hive.ql.udf;

then your add function definition becomes

CREATE TEMPORARY FUNCTION <function_name> AS
'org.apache.hadoop.hive.ql.udf.<ClassName>';

feel free to use any package name you wish but make sure its reflected same

also to build and compile and package hive udfs
use the shell script if you are on linux

http://yaboolog.blogspot.in/2011/06/compiling-original-hive-udf.html



On Wed, Apr 9, 2014 at 12:12 PM, Rishabh Bhardwaj <rbnex...@yahoo.com>wrote:

> 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<https://github.com/rathboma/hive-extension-examples/blob/master/src/main/java/com/matthewrathbone/example/SimpleUDFExample.java>
> ).
>
>   On Wednesday, 9 April 2014 12:08 PM, Nitin Pawar <
> nitinpawar...@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 <rbnex...@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<http://blog.matthewrathbone.com/2013/08/10/guide-to-writing-hive-udfs.html>
> .
> 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
>
>
>


-- 
Nitin Pawar

Reply via email to