Reputation: 237
I have created the following script wherein I am trying to use the piggybank UDF:
register /home/hduser/pig/contrib/piggybank/java/piggybank.jar;
divs = load 'NYSE_dividends.txt' using PigStorage(',') as (exchange:chararray, symbol:chararray, date:chararray, dividends:float);
backwards = foreach divs generate
org.apache.pig.piggybank.evaluation.string.Reverse(symbol);
store backwards into '/user/hduser/backwards.csv';
When I run the above line by line in GRUNT shell it works fine however, when I try to run it as a script the following error comes up:
2014-03-10 22:42:25,375 [main] ERROR org.apache.pig.tools.grunt.Grunt - ERROR 1000: Error during parsing. File not found: /user/hduser/register.pig
I am using HADOOP 1.2.1 and PIG 0.12 in pseudocluster mode.
The log is below:
Pig Stack Trace
---------------
ERROR 1000: Error during parsing. File not found: register.pig
org.apache.pig.tools.pigscript.parser.ParseException: File not found: register.pig
at org.apache.pig.tools.grunt.GruntParser.loadScript(GruntParser.java:547)
at org.apache.pig.tools.grunt.GruntParser.processScript(GruntParser.java:509)
at org.apache.pig.tools.pigscript.parser.PigScriptParser.Script(PigScriptParser.java:1014)
at org.apache.pig.tools.pigscript.parser.PigScriptParser.parse(PigScriptParser.java:550)
at org.apache.pig.tools.grunt.GruntParser.parseStopOnError(GruntParser.java:198)
at org.apache.pig.tools.grunt.GruntParser.parseStopOnError(GruntParser.java:173)
at org.apache.pig.tools.grunt.Grunt.run(Grunt.java:69)
at org.apache.pig.Main.run(Main.java:541)
at org.apache.pig.Main.main(Main.java:156)
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:606)
at org.apache.hadoop.util.RunJar.main(RunJar.java:160)
Upvotes: 1
Views: 982
Reputation: 2333
I think you're using the example from "Programming Pig" (Author Alan Gates, 2011, O'Reilly Media), which has a program called "register.pig". One piece of information you're not showing here is how you've executed the command, so I'm guessing that you ran:
pig -f /user/hduser/register.pig
This path looks like it's referencing HDFS, but the file should be on your local filesystem, so you should try
pig -f /local/path/register.pig
Note: You can also register UDFs on the command line when executing your script, too. This way you don't have to register it inside the script, if you prefer not to.
pig -f /local/path/register.pig -Dpig.additional.jars=/home/hduser/pig/contrib/piggybank/java/piggybank.jar
Upvotes: 1