我创建了以下脚本,其中我尝试使用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';
当我在GRUNT shell中逐行运行时,它工作正常,但是当我尝试将其作为脚本运行时出现以下错误:
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
我在伪簇模式下使用HADOOP 1.2.1和PIG 0.12。
日志如下:
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)
答案 0 :(得分:1)
我认为你正在使用“Programming Pig”中的例子(作者Alan Gates,2011,O'Reilly Media),它有一个名为“register.pig”的程序。你没有在这里展示的一条信息是你如何执行命令,所以我猜你跑了:
pig -f /user/hduser/register.pig
此路径看起来像是引用HDFS,但该文件应该在您的本地文件系统上,因此您应该尝试
pig -f /local/path/register.pig
注意:您也可以在执行脚本时在命令行上注册UDF。这样,如果您不愿意,则不必在脚本中注册它。
pig -f /local/path/register.pig -Dpig.additional.jars=/home/hduser/pig/contrib/piggybank/java/piggybank.jar