0

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.

Community
  • 1
  • 1
tom
  • 719
  • 1
  • 11
  • 30
  • Does a more trivial version of your script and/or UDF work? By starting from a trivial base and gradually building up you should be able to find which part causes the problem. -- For people who found this post when looking for [ERROR 1066: Unable to open iterator for alias](http://stackoverflow.com/questions/34495085/error-1066-unable-to-open-iterator-for-alias-in-pig-generic-solution) here is a [generic solution](http://stackoverflow.com/a/34495086/983722). – Dennis Jaheruddin Dec 28 '15 at 15:29

1 Answers1

0

Most probably your UDF failed, that's why you have no result relation. Is the code you're using working/tested?

kecso
  • 2,387
  • 2
  • 18
  • 29