First of all, I am almost new to Pig and I am using it because my organization supports it. Now, I am reading json files (not using elephntBird knowingly because of its limitations as Jackson parser can do a lot than this) from a directory by:
json = LOAD '/user/json_data' USING TextLoader AS (line: chararray);
When I say dump json, it displays me the content of all available json files under /user/json_data directory. Now I am using my UDF to parse these json files and insert the data into Cassandra. Pig statement is :
result = FOREACH json GENERATE com.myorg.pig.UDF(line);
But when I do dump result it shows me below exception:
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
My UDF is :
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";
}
}
}
I have seen several answers here but no improvement found. Please provide any input and suggest alternatives if I am doing it in wrong way.