Home | About | Sematext search-lucene.com search-hadoop.com
 Search Hadoop and all its subprojects:

Switch to Threaded View
Pig, mail # user - A question on joins


Copy link to this message
-
A question on joins
Sameer Tilak 2013-06-19, 07:10
Dear Pig users,
I am trying to do simple joins by following an example on a Blog. Your help will be great.
 
UserDetails.txt
123456, Jim
456123, Tom
789123, Harry
789456, Richa

DeliveryDetails.txt
123456, 001
456123, 002
789123, 003
789456, 004

DeliveryStatusCodes.txt
001, Delivered
002, Pending
003, Failed
004, Resend

Expected o/p
Jim Delivered
.....

grunt> userdetails = load 'UserDetails.txt' as (mobile, username);

grunt> deliverydetails = load 'DeliveryDetails.txt' as (mobile , deliverycode);

grunt> userdeliverydetails = join userdetails BY mobile, deliverydetails BY mobile;

grunt> describe userdeliverydetails
userdeliverydetails: {userdetails::mobile: bytearray,userdetails::username: bytearray,deliverydetails::mobile: bytearray,deliverydetails::deliverycode: bytearray}

grunt> deliverystatuscodes = load 'DeliveryStatusCodes.txt' as (deliverycode, message);

grunt>  output = join userdeliverydetails by $3, deliverystatuscodes by $0;

2013-06-19 00:02:31,600 [main] ERROR org.apache.pig.tools.grunt.Grunt - ERROR 1200: <line 8, column 0>  mismatched input 'output' expecting EOF
Details at logfile: pig_1371623265656.log. I have copied the details here:
-:---F1  *scratch*      All L1     (Fundamental)-----------------------------
Pig Stack Trace
---------------
ERROR 2997: Encountered IOException. Exception

java.io.IOException: Exception
        at org.apache.pig.PigServer.getExamples(PigServer.java:1186)
        at org.apache.pig.tools.grunt.GruntParser.processIllustrate(GruntParser\
.java:739)
        at org.apache.pig.tools.pigscript.parser.PigScriptParser.Illustrate(Pig\
ScriptParser.java:626)
        at org.apache.pig.tools.pigscript.parser.PigScriptParser.parse(PigScrip\
tParser.java:323)
        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)
Caused by: java.lang.RuntimeException: No (valid) input data found!
        at org.apache.pig.pen.AugmentBaseDataVisitor.visit(AugmentBaseDataVisit\
or.java:583)
-uu-:---F1  pig_1371623265656.log   Top L1     (Fundamental)--------------------
Loading image...done
Pig Stack Trace
---------------
ERROR 2997: Encountered IOException. Exception

java.io.IOException: Exception
        at org.apache.pig.PigServer.getExamples(PigServer.java:1186)
        at org.apache.pig.tools.grunt.GruntParser.processIllustrate(GruntParser.\
java:739)
        at org.apache.pig.tools.pigscript.parser.PigScriptParser.Illustrate(PigS\
criptParser.java:626)
        at org.apache.pig.tools.pigscript.parser.PigScriptParser.parse(PigScript\
Parser.java:323)
        at org.apache.pig.tools.grunt.GruntParser.parseStopOnError(GruntParser.j\
ava:194)
        at org.apache.pig.tools.grunt.GruntParser.parseStopOnError(GruntParser.j\
ava: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)
Caused by: java.lang.RuntimeException: No (valid) input data found!
        at org.apache.pig.pen.AugmentBaseDataVisitor.visit(AugmentBaseDataVisito\
r.java:583)
-uu-:---F1  pig_1371623265656.log   Top L1     (Fundamental)---------------------
Loading image...done
Pig Stack Trace
---------------
ERROR 2997: Encountered IOException. Exception

java.io.IOException: Exception
        at org.apache.pig.PigServer.getExamples(PigServer.java:1186)
        at org.apache.pig.tools.grunt.GruntParser.processIllustrate(GruntParser.j\
ava:739)
        at org.apache.pig.tools.pigscript.parser.PigScriptParser.Illustrate(PigSc\
riptParser.java:626)
        at org.apache.pig.tools.pigscript.parser.PigScriptParser.parse(PigScriptP\
arser.java:323)
        at org.apache.pig.tools.grunt.GruntParser.parseStopOnError(GruntParser.ja\
va:194)
        at org.apache.pig.tools.grunt.GruntParser.parseStopOnError(GruntParser.ja\
va: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)
Caused by: java.lang.RuntimeException: No (valid) input data found!
        at org.apache.pig.pen.AugmentBaseDataVisitor.visit(AugmentBaseDataVisitor\
.java:583)
        at org.apache.pig.newplan.logical.relational.LOLoad.accept(LOLoad.java:22\
-uu-:---F1  pig_1371623265656.log   Top L1     (Fundamental)----------------------
Loading image...done
Pig Stack Trace
ERROR 2997: Encountered IOException. Exception

java.io.IOException: Exception
        at org.apache.pig.PigServer.getExamples(PigServer.java:1186)
        at org.apache.pig.tools.grunt.GruntParser.processIllustrate(GruntParser.jav\
a:739)
        at org.apache.pig.tools.pigscript.parser.PigScriptParser.Illustrate(PigScri\
ptParser.java:626)
        at org.apache.pig.tools.pigscript.parser.PigScriptParser.parse(PigScriptPar\
ser.java:323)
        at org.apache.pig.tools.grunt.GruntParser.parseStopOnError(GruntParser.java\
        at org.apache.pig.tools.grunt.GruntParser.parseStopOnError(GruntParser.java\
        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)
Caused by: java.lang.RuntimeException: No (valid) input data found!
        at org.apache.pig.pen.AugmentBaseDataVisitor.visit(AugmentBaseDataVisitor.j\
ava:583)
        at org.apache.pig.newplan.logical.relational.LOLoad.accept(LOLoad.java:229)
        at org.apache.pig.pen.util.PreOrderDepthFirstWalker.depthFirst(PreOrderDept\
-uu-:---F1  pig_1371623265656.log   Top L1     (Fundamental)------------------------
Loading image...done
Pig Stack Trace
ERROR 2997: Encountered IOException. Exception

java.io.IOException: Exception
        at org.apache.pig.PigServer.getExamples(PigServer.java:1186)