首先,我对pig几乎是新手,我之所以使用它是因为我的组织支持它。现在,我正在通过以下方式从目录中读取json文件(由于其局限性,我无意中使用elephntbird,因为jackson parser可以做很多事情):
json = LOAD '/user/json_data' USING TextLoader AS (line: chararray);
当我说dump json时,它会显示/user/json\u data目录下所有可用json文件的内容。现在我使用我的udf来解析这些json文件,并将数据插入cassandra。pig声明是:
result = FOREACH json GENERATE com.myorg.pig.UDF(line);
但当我转储结果时,它会显示以下异常:
Pig Stack Trace
---------------
ERROR 2997: Unable to recreate exception from backed error: Error: com.google.common.util.concurrent.Futures.withFallback(Lcom/google/common/util/concurrent/ListenableFuture;Lcom/google/common/util/concurrent/FutureFallback;Ljava/util/concurrent/Executor;)Lcom/google/common/util/concurrent/ListenableFuture;
org.apache.pig.impl.logicalLayer.FrontendException: ERROR 1066: Unable to open iterator for alias result. Backend error : Unable to recreate exception from backed error: Error: com.google.common.util.concurrent.Futures.withFallback(Lcom/google/common/util/concurrent/ListenableFuture;Lcom/google/common/util/concurrent/FutureFallback;Ljava/util/concurrent/Executor;)Lcom/google/common/util/concurrent/ListenableFuture;
at org.apache.pig.PigServer.openIterator(PigServer.java:828)
at org.apache.pig.tools.grunt.GruntParser.processDump(GruntParser.java:696)
at org.apache.pig.tools.pigscript.parser.PigScriptParser.parse(PigScriptParser.java:320)
at org.apache.pig.tools.grunt.GruntParser.parseStopOnError(GruntParser.java:194)
at org.apache.pig.tools.grunt.GruntParser.parseStopOnError(GruntParser.java:170)
at org.apache.pig.tools.grunt.Grunt.run(Grunt.java:69)
at org.apache.pig.Main.run(Main.java:538)
at org.apache.pig.Main.main(Main.java:157)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.hadoop.util.RunJar.main(RunJar.java:208)
Caused by: org.apache.pig.backend.executionengine.ExecException: ERROR 2997: Unable to recreate exception from backed error: Error: com.google.common.util.concurrent.Futures.withFallback(Lcom/google/common/util/concurrent/ListenableFuture;Lcom/google/common/util/concurrent/FutureFallback;Ljava/util/concurrent/Executor;)Lcom/google/common/util/concurrent/ListenableFuture;
at org.apache.pig.backend.hadoop.executionengine.mapReduceLayer.Launcher.getErrorMessages(Launcher.java:217)
at org.apache.pig.backend.hadoop.executionengine.mapReduceLayer.Launcher.getStats(Launcher.java:149)
at org.apache.pig.backend.hadoop.executionengine.mapReduceLayer.MapReduceLauncher.launchPig(MapReduceLauncher.java:400)
at org.apache.pig.PigServer.launchPlan(PigServer.java:1266)
at org.apache.pig.PigServer.executeCompiledLogicalPlan(PigServer.java:1251)
at org.apache.pig.PigServer.storeEx(PigServer.java:933)
at org.apache.pig.PigServer.store(PigServer.java:900)
at org.apache.pig.PigServer.openIterator(PigServer.java:813)
... 12 more
我的自定义项是:
public class UDF extends EvalFunc<String> {
@Override
public String exec(Tuple tuple) throws IOException {
if (null == tuple || tuple.size() != 1)
return "bad input";
try {
String file = (String) tuple.get(0);
DynamicJsonFlattener obl=new DynamicJsonFlattener(null);
obl.processJsonToCassandra(file);
return "processed successfully";
} catch (Exception e) {
return "error";
}
}
}
我在这里看到了几个答案,但没有发现改进。请提供任何意见和建议的替代品,如果我这样做是在错误的方式。
1条答案
按热度按时间bpsygsoo1#
很可能你的自定义项失败了,这就是为什么你没有结果关系。您使用的代码是否正常工作/经过测试?