Home | About | Sematext search-lucene.com search-hadoop.com
NEW: Monitor These Apps!
elasticsearch, apache solr, apache hbase, hadoop, redis, casssandra, amazon cloudwatch, mysql, memcached, apache kafka, apache zookeeper, apache storm, ubuntu, centOS, red hat, debian, puppet labs, java, senseiDB
 Search Hadoop and all its subprojects:

Switch to Threaded View
Pig >> mail # user >> why the udf can not work


Copy link to this message
-
Re: why the udf can not work
You need to have your class file in this path

/home/huyong/test/myudfs/UPPER.class

since it's in myudfs directory.
On Jun 18, 2011, at 12:33 PM, 锟铰猴拷 <[EMAIL PROTECTED]> wrote:

> I tried your command and then it shows me as following:
> /home/huyong/test/UPPER.class
> /home/huyong/test/UPPER.java
>
> Yong
> 锟斤拷 2011锟斤拷6锟斤拷18锟斤拷 锟斤拷锟斤拷4:29锟斤拷Dmitriy Ryaboy <[EMAIL PROTECTED]>写锟斤拷锟斤拷
>
>> This usually hapens when you aren't registering what you think you are
>> registering.
>> try `jar tf /home/huyong/test/myudfs.jar | grep UPPER` and see if you
>> get anything.
>>
>> D
>>
>> 2011/6/18 锟铰猴拷 <[EMAIL PROTECTED]>:
>>> Hi,
>>>
>>> package myudfs;
>>> import java.io.IOException;
>>> import org.apache.pig.EvalFunc;
>>> import org.apache.pig.data.Tuple;
>>> import org.apache.pig.impl.util.*;
>>>
>>> public class UPPER extends EvalFunc<String>
>>> {
>>>   public String exec(Tuple input) throws IOException {
>>>       if (input == null || input.size() == 0)
>>>           return null;
>>>       try{
>>>           String str = (String)input.get(0);
>>>           return str.toUpperCase();
>>>       }catch(Exception e){
>>>           throw new IOException(e);
>>>       }
>>>   }
>>> }
>>>
>>> This is as same as the example from the Pig website. By the way, I also
>>> added the PIG_CLASS. But it still didn't work.
>>>
>>> Yong
>>>
>>> 2011/6/18 Jonathan Coveney <[EMAIL PROTECTED]>
>>>
>>>> Can you paste the content of the UDF?
>>>>
>>>> 2011/6/18 锟铰猴拷 <[EMAIL PROTECTED]>
>>>>
>>>>> Hello,
>>>>>
>>>>> I just tried the example from the pig udf manual step by step. But I
>> got
>>>>> the
>>>>> error information. Can anyone tell me how to solve it?
>>>>>
>>>>> grunt> REGISTER /home/huyong/test/myudfs.jar;
>>>>> grunt> A = LOAD '/home/huyong/test/student.txt' as (name:chararray);
>>>>> grunt> B = FOREACH A GENERATE myudfs.UPPER(name);
>>>>> 2011-06-18 11:15:38,892 [main] ERROR org.apache.pig.tools.grunt.Grunt
>> -
>>>>> ERROR 1070: Could not resolve myudfs.UPPER using imports: [,
>>>>> org.apache.pig.builtin., org.apache.pig.impl.builtin.]
>>>>> Details at logfile: /home/huyong/test/pig_1308388238352.log
>>>>>
>>>>> I have already registered the udf, why pig tries to search from the
>>>> builtin
>>>>> path.
>>>>>
>>>>> Thanks for your help!
>>>>>
>>>>> Yong Hu
>>>>>
>>>>
>>>
>>
NEW: Monitor These Apps!
elasticsearch, apache solr, apache hbase, hadoop, redis, casssandra, amazon cloudwatch, mysql, memcached, apache kafka, apache zookeeper, apache storm, ubuntu, centOS, red hat, debian, puppet labs, java, senseiDB