Syntax error when line break and tab involved
---------------------------------------------

                 Key: PIG-2414
                 URL: https://issues.apache.org/jira/browse/PIG-2414
             Project: Pig
          Issue Type: Bug
    Affects Versions: 0.9.0, 0.8.1
            Reporter: Anitha Raju


Hi,

The following script fails with syntax error 

Script
{code}
A = load 'test.txt' as (a:int,b:long);
B = group A by a;
C = foreach B generate
        flatten((IsEmpty(A) ? {(0)} : {(1)}));
{code}

where "generate" and "flatten" are separated by line break and a tab. 

This script fails with the following exception 

{code}
ERROR 1200: <file bug.pig, line 4, column 8>  Syntax error, unexpected symbol 
at or near '('

Failed to parse: <file bug.pig, line 4, column 8>  Syntax error, unexpected 
symbol at or near '('
        at 
org.apache.pig.parser.QueryParserDriver.parse(QueryParserDriver.java:222)
        at 
org.apache.pig.parser.QueryParserDriver.parse(QueryParserDriver.java:164)
        at org.apache.pig.PigServer$Graph.validateQuery(PigServer.java:1609)
        at org.apache.pig.PigServer$Graph.registerQuery(PigServer.java:1582)
        at org.apache.pig.PigServer.registerQuery(PigServer.java:584)
        at 
org.apache.pig.tools.grunt.GruntParser.processPig(GruntParser.java:939)
        at 
org.apache.pig.tools.pigscript.parser.PigScriptParser.parse(PigScriptParser.java:386)
        at 
org.apache.pig.tools.grunt.GruntParser.loadScript(GruntParser.java:516)
        at 
org.apache.pig.tools.grunt.GruntParser.processExplain(GruntParser.java:314)
        at org.apache.pig.tools.grunt.Grunt.checkScript(Grunt.java:95)
        at org.apache.pig.Main.run(Main.java:557)
        at org.apache.pig.Main.main(Main.java:111)
{code}

Even without flatten it would fail. 

-------------
((IsEmpty(A) ? {(0)} : {(1)}));
-------------

Here are some cases where it would work
-> flatten put in the same line as foreach (tab or space seperated)

{code}
A = load 'test.txt' as (a:int,b:long);
B = group A by a;
C = foreach B generate        flatten((IsEmpty(A) ? {(0)} : {(1)}));
{code}

-> a space and a line break and a tab between flatten and generate, the script 
passes

{code}
A = load 'test.txt' as (a:int,b:long);
B = group A by a;
C = foreach B generate <space>
        flatten((IsEmpty(A) ? {(0)} : {(1)}));
{code}

This fails with both 0.8 and 0.9.

Regards,
Anitha




--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to