You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pig.apache.org by "Xuefu Zhang (JIRA)" <ji...@apache.org> on 2011/03/10 02:03:59 UTC

[jira] Commented: (PIG-596) Anonymous tuples in bags create ParseExceptions

    [ https://issues.apache.org/jira/browse/PIG-596?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13004910#comment-13004910 ] 

Xuefu Zhang commented on PIG-596:
---------------------------------

The old parser requires a name for the tuple type in a bag type. This requirement is dropped in the new parser. Thus, the following query works:

One = load 'one.txt' using PigStorage() as ( one: int );
LabelledTupleInBag = foreach One generate { ( 1, 2 ) } as mybag : { tuplelabel: tuple ( a, b ) };
AnonymousTupleInBag = foreach One generate { ( 2, 3 ) } as mybag : { ( a, b ) };

However, you do need separate field alias and its type with a ":", as shown above.

> Anonymous tuples in bags create ParseExceptions
> -----------------------------------------------
>
>                 Key: PIG-596
>                 URL: https://issues.apache.org/jira/browse/PIG-596
>             Project: Pig
>          Issue Type: Bug
>    Affects Versions: 0.2.0
>            Reporter: David Ciemiewicz
>            Assignee: Xuefu Zhang
>             Fix For: 0.9.0
>
>
> {code}
> One = load 'one.txt' using PigStorage() as ( one: int );
> LabelledTupleInBag = foreach One generate { ( 1, 2 ) } as mybag { tuplelabel: tuple ( a, b ) };
> AnonymousTupleInBag = foreach One generate { ( 2, 3 ) } as mybag { tuple ( a, b ) }; -- Anonymous tuple creates bug
> Tuples = union LabelledTupleInBag, AnonymousTupleInBag;
> dump Tuples;
> {code}
> java.io.IOException: Encountered "{ tuple" at line 6, column 66.
> Was expecting one of:
>     "parallel" ...
>     ";" ...
>     "," ...
>     ":" ...
>     "(" ...
>     "{" <IDENTIFIER> ...
>     "{" "}" ...
>     "[" ...
>     
>         at org.apache.pig.PigServer.parseQuery(PigServer.java:298)
>         at org.apache.pig.PigServer.registerQuery(PigServer.java:263)
>         at org.apache.pig.tools.grunt.GruntParser.processPig(GruntParser.java:439)
>         at org.apache.pig.tools.pigscript.parser.PigScriptParser.parse(PigScriptParser.java:249)
>         at org.apache.pig.tools.grunt.GruntParser.parseStopOnError(GruntParser.java:84)
>         at org.apache.pig.tools.grunt.Grunt.exec(Grunt.java:64)
>         at org.apache.pig.Main.main(Main.java:306)
> Caused by: org.apache.pig.impl.logicalLayer.parser.ParseException: Encountered "{ tuple" at line 6, column 66.
> Why can't there be an anonymous tuple at the top level of a bag?

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira