Reputation: 1
I am new to PIG and I wrote a UDF in java and copied and used the following commands to compile the java class with pig-version.jar (I am using pig-0.11.1 and hadoop-1.2.1).
>cd udfs
>java -cp $PIG_HOME/pig-0.11.1.jar UPPER.java
It prompted me with the following lines
Note: UPPER.java uses or overrides a deprecated API. Note: Recompile with -Xlint:deprecation for details.
I though its just a warning and built a jar file for udfs folder
>jar -cf udfs.jar udfs
Then I ran the following pig script some.pig
REGISTER udfs.jar;
DEFINE udfs.UPPER();
A= load 'input' using PigStorage(',') as (fname:chararray,lname:chararray,age:int);
B = foreach A generate udfs.UPPER(fname);
store B into 'some-output3' using PigStorage(',');
I ran the script using command
>pig -x local some.pig
It gave me the following error
Warning: $HADOOP_HOME is deprecated.
2014-02-22 12:50:28,524 [main] INFO org.apache.pig.Main - Apache Pig version 0.11.1 (r1459641) compiled Mar 22 2013, 02:13:53
2014-02-22 12:50:28,525 [main] INFO org.apache.pig.Main - Logging error messages to: /home/vamshi23/pig-area/pig_1393102228520.log
2014-02-22 12:50:28,985 [main] INFO org.apache.pig.impl.util.Utils - Default bootup file /root/.pigbootup not found
2014-02-22 12:50:29,273 [main] INFO org.apache.pig.backend.hadoop.executionengine.HExecutionEngine - Connecting to hadoop file system at: file:///
2014-02-22 12:50:30,374 [main] ERROR org.apache.pig.tools.grunt.Grunt - ERROR 1200: <file some.pig, line 3, column 11> Syntax error, unexpected symbol at or near '.'
Details at logfile: /home/vamshi23/pig-area/pig_1393102228520.log
Could someone please help me resolve this issue?
Thank you, Vamshi
Upvotes: 0
Views: 414
Reputation: 458
I think the problem may be in your usage of DEFINE. Your usage of it should appear like this:
DEFINE Upper udfs.UPPER();
The first part is the alias that you use to reference the UDF later.
You can then use it like this:
B = foreach A generate Upper(fname);
Note that Pig already has an UPPER UDF defined. I'm not sure if this will cause a conflict so I changed the casing, which I think avoids this.
You should also be able to use your UPPER UDF without defining it first. Just remove the line where you invoke DEFINE and use what you originally had:
B = foreach A generate udfs.UPPER(fname);
Check out the Pig documentation on UDFs here for more info.
Upvotes: 1