0
votes

I am trying to use python udf but it is throwing below error. I am using CDH5.2

cat /home/spanda20/pig_data/panda1.py
def get_length(data):
    return len(data)

REGISTER '/home/spanda20/pig_data/panda1.py' USING jython  as my_udf;

grunt>  A = LOAD 'hdfs://itsusmpl00509.jnj.com:8020/user/spanda20/pig_1.dat' USING PigStorage(',') AS (name:chararray, id:int);
grunt>  B = FOREACH A GENERATE name, id,my_udf.get_length(name) as name_len;

2015-01-25 20:47:15,243 [main] ERROR org.apache.pig.tools.grunt.Grunt - ERROR 1070: Could not resolve my_udf.get_length using imports: [, java.lang., org.apache.pig.builtin., org.apache.pig.impl.builtin.] Details at logfile: /home/spanda20/pig_1422230028021.log

1
what is the content in home/spanda20/pig_1422230028021.logvishnu viswanath
Can you post the pertinent parts of that logfile? I was able to run your UDF successfully on HDP 2.2 (Pig 0.14, Hadoop 2.6) with a minimal test set of data.rchang
ERROR 1070: Could not resolve my_udf.get_length using imports: [, java.lang., org.apache.pig.builtin., org.apache.pig.impl.builtin.] Failed to parse: Pig script failed to parse: <line 14, column 32> Failed to generate logical plan. Nested exception: org.apache.pig.backend.executionengine.ExecException: ERROR 1070: Could not resolve my_udf.get_length using imports: [, java.lang., org.apache.pig.builtin., org.apache.pig.impl.builtin.]user3858193
when you ran the REGISTER command, what was the console response?vishnu viswanath
it looks like the register is not working. Try to close the pig client. Open the client again. And run your commands.vishnu viswanath

1 Answers

4
votes

Sometimes, after a pig REGISTER command fails for UDF, you might have to restart the client for PIG to reload the UDF