错误:Pig Local模式下的JsonStorage

时间:2015-07-16 02:58:43

标签: json format apache-pig

我在eclipse中以本地模式运行我的Pigscript。 当我尝试将输出存储在JsonStorage中时。

Exception in thread "main" java.lang.RuntimeException: Cannot instantiate:org.apache.pig.builtin.JsonStorage
    at org.apache.pig.impl.PigContext.instantiateFuncFromSpec(PigContext.java:473)
    at org.apache.pig.impl.logicalLayer.parser.QueryParser.NonEvalFuncSpec(QueryParser.java:4976)
    at org.apache.pig.impl.logicalLayer.parser.QueryParser.StoreClause(QueryParser.java:3473)
    at org.apache.pig.impl.logicalLayer.parser.QueryParser.BaseExpr(QueryParser.java:1351)
    at org.apache.pig.impl.logicalLayer.parser.QueryParser.Expr(QueryParser.java:893)
    at org.apache.pig.impl.logicalLayer.parser.QueryParser.Parse(QueryParser.java:706)
    at org.apache.pig.impl.logicalLayer.LogicalPlanBuilder.parse(LogicalPlanBuilder.java:63)
    at org.apache.pig.PigServer$Graph.parseQuery(PigServer.java:1017)
    at org.apache.pig.PigServer$Graph.registerQuery(PigServer.java:967)
    at org.apache.pig.PigServer.registerQuery(PigServer.java:383)
    at org.apache.pig.tools.grunt.GruntParser.processPig(GruntParser.java:716)
    at org.apache.pig.tools.pigscript.parser.PigScriptParser.parse(PigScriptParser.java:324)
    at org.apache.pig.tools.grunt.GruntParser.parseStopOnError(GruntParser.java:168)
    at org.apache.pig.PigServer.registerScript(PigServer.java:407)
    at com.paypal.debugpig.DebugPig.main(DebugPig.java:13)
Caused by: org.apache.pig.backend.executionengine.ExecException: ERROR 1070: Could not resolve org.apache.pig.builtin.JsonStorage using imports: [, org.apache.pig.builtin., org.apache.pig.impl.builtin.]
    at org.apache.pig.impl.PigContext.resolveClassName(PigContext.java:458)
    at org.apache.pig.impl.PigContext.instantiateFuncFromSpec(PigContext.java:470)
    ... 14 more

PigScript:

REGISTER C:/path/to/jar/pig.jar;
REGISTER C:/path/to/jar/UpperUDf/UpperUDf_fat.jar;

A = LOAD 'C:/path/to/data/file/student.txt' using PigStorage('\t') AS (name: chararray, age: int, gpa: float);
B = FOREACH A GENERATE myudfs.UPPER(name) ,age, gpa ;

Store B into 'output_student_Json' using org.apache.pig.builtin.JsonStorage();

当我将输出转储或存储在文本文件中时,它正在工作,但当我尝试以JSON格式存储时会出现问题。 任何指针赞赏 谢谢

1 个答案:

答案 0 :(得分:0)

我已经验证了它,如果我使用下面的代码行将输出存储为json文件格式,它对我有用。

store B into 'json_output' using JsonStorage();