You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pig.apache.org by xu...@apache.org on 2011/05/13 20:12:38 UTC

svn commit: r1102842 - in /pig/branches/branch-0.9: ./ src/org/apache/pig/parser/ test/org/apache/pig/parser/ test/org/apache/pig/test/

Author: xuefu
Date: Fri May 13 18:12:38 2011
New Revision: 1102842

URL: http://svn.apache.org/viewvc?rev=1102842&view=rev
Log:
PIG-2062: Script silently ended

Modified:
    pig/branches/branch-0.9/CHANGES.txt
    pig/branches/branch-0.9/src/org/apache/pig/parser/QueryParser.g
    pig/branches/branch-0.9/test/org/apache/pig/parser/TestLogicalPlanGenerator.java
    pig/branches/branch-0.9/test/org/apache/pig/test/TestCombiner.java
    pig/branches/branch-0.9/test/org/apache/pig/test/TestExampleGenerator.java
    pig/branches/branch-0.9/test/org/apache/pig/test/TestLogicalPlanBuilder.java

Modified: pig/branches/branch-0.9/CHANGES.txt
URL: http://svn.apache.org/viewvc/pig/branches/branch-0.9/CHANGES.txt?rev=1102842&r1=1102841&r2=1102842&view=diff
==============================================================================
--- pig/branches/branch-0.9/CHANGES.txt (original)
+++ pig/branches/branch-0.9/CHANGES.txt Fri May 13 18:12:38 2011
@@ -34,6 +34,8 @@ PIG-1876: Typed map for Pig (daijy)
 
 IMPROVEMENTS
 
+PIG-2062: Script silently ended (xuefu)
+
 PIG-2039: IndexOutOfBounException for a case (xuefu)
 
 PIG-2038: Pig fails to parse empty tuple/map/bag constant (xuefu)

Modified: pig/branches/branch-0.9/src/org/apache/pig/parser/QueryParser.g
URL: http://svn.apache.org/viewvc/pig/branches/branch-0.9/src/org/apache/pig/parser/QueryParser.g?rev=1102842&r1=1102841&r2=1102842&view=diff
==============================================================================
--- pig/branches/branch-0.9/src/org/apache/pig/parser/QueryParser.g (original)
+++ pig/branches/branch-0.9/src/org/apache/pig/parser/QueryParser.g Fri May 13 18:12:38 2011
@@ -135,10 +135,8 @@ catch(RecognitionException re) {
 }
 }
 
-query : statement+ 
-     -> ^( QUERY statement+ )
-      |
-     -> ^( QUERY )
+query : statement* EOF
+     -> ^( QUERY statement* )
 ;
 
 statement : SEMI_COLON!

Modified: pig/branches/branch-0.9/test/org/apache/pig/parser/TestLogicalPlanGenerator.java
URL: http://svn.apache.org/viewvc/pig/branches/branch-0.9/test/org/apache/pig/parser/TestLogicalPlanGenerator.java?rev=1102842&r1=1102841&r2=1102842&view=diff
==============================================================================
--- pig/branches/branch-0.9/test/org/apache/pig/parser/TestLogicalPlanGenerator.java (original)
+++ pig/branches/branch-0.9/test/org/apache/pig/parser/TestLogicalPlanGenerator.java Fri May 13 18:12:38 2011
@@ -23,6 +23,7 @@ import java.io.IOException;
 
 import junit.framework.Assert;
 
+import org.antlr.runtime.MismatchedTokenException;
 import org.antlr.runtime.NoViableAltException;
 import org.apache.pig.test.Util;
 import org.junit.BeforeClass;
@@ -297,7 +298,23 @@ public class TestLogicalPlanGenerator {
     	try {
             ParserTestingUtils.generateLogicalPlan( query );
         } catch(Exception ex) {
-            Assert.assertTrue( ex instanceof NoViableAltException );
+            Assert.assertTrue( ex instanceof MismatchedTokenException );
+            MismatchedTokenException mex = (MismatchedTokenException)ex;
+            Assert.assertTrue( mex.token.getText().equals("ship") );
+            return;
+        }
+        Assert.fail( "Query is supposed to be failing." );
+    }
+
+    @Test
+    public void testNegative3() {
+    	String query = "A = load 'y'; all = load 'x';";
+    	try {
+            ParserTestingUtils.generateLogicalPlan( query );
+        } catch(Exception ex) {
+            Assert.assertTrue( ex instanceof MismatchedTokenException );
+            MismatchedTokenException mex = (MismatchedTokenException)ex;
+            Assert.assertTrue( mex.token.getText().equals("all") );
             return;
         }
         Assert.fail( "Query is supposed to be failing." );

Modified: pig/branches/branch-0.9/test/org/apache/pig/test/TestCombiner.java
URL: http://svn.apache.org/viewvc/pig/branches/branch-0.9/test/org/apache/pig/test/TestCombiner.java?rev=1102842&r1=1102841&r2=1102842&view=diff
==============================================================================
--- pig/branches/branch-0.9/test/org/apache/pig/test/TestCombiner.java (original)
+++ pig/branches/branch-0.9/test/org/apache/pig/test/TestCombiner.java Fri May 13 18:12:38 2011
@@ -486,8 +486,7 @@ public class TestCombiner {
             PigServer pigServer = new PigServer(ExecType.MAPREDUCE, cluster.getProperties());
             pigServer.registerQuery("a = load 'forEachNoCombinerInput.txt' as (name:chararray, age:int, gpa:double);");
             pigServer.registerQuery("b = group a by name;");
-            pigServer.registerQuery("c = foreach b " +
-                    "        generate group, SUM(a.age), a;};");
+            pigServer.registerQuery("c = foreach b generate group, SUM(a.age), a;");
             
             // make sure there isn't a combine plan in the explain output
             ByteArrayOutputStream baos = new ByteArrayOutputStream();

Modified: pig/branches/branch-0.9/test/org/apache/pig/test/TestExampleGenerator.java
URL: http://svn.apache.org/viewvc/pig/branches/branch-0.9/test/org/apache/pig/test/TestExampleGenerator.java?rev=1102842&r1=1102841&r2=1102842&view=diff
==============================================================================
--- pig/branches/branch-0.9/test/org/apache/pig/test/TestExampleGenerator.java (original)
+++ pig/branches/branch-0.9/test/org/apache/pig/test/TestExampleGenerator.java Fri May 13 18:12:38 2011
@@ -242,7 +242,7 @@ public class TestExampleGenerator extend
         PigServer pigServer = new PigServer(pigContext);
         pigServer.registerQuery("A = load " + A.toString() + " as (x:int, y:int);");
         pigServer.registerQuery("B = group A by x;");
-        pigServer.registerQuery("C = foreach B generate group, COUNT(A);};");
+        pigServer.registerQuery("C = foreach B generate group, COUNT(A);");
         Map<Operator, DataBag> derivedData = pigServer.getExamples("C");
 
         assertTrue(derivedData != null);
@@ -255,7 +255,7 @@ public class TestExampleGenerator extend
         pigServer.registerQuery("A = load " + A.toString() + " as (x:int, y:int);");
         pigServer.registerQuery("B = FILTER A by x  > 3;");
         pigServer.registerQuery("C = group B by y;");
-        pigServer.registerQuery("D = foreach C generate group, COUNT(B);};");
+        pigServer.registerQuery("D = foreach C generate group, COUNT(B);");
         Map<Operator, DataBag> derivedData = pigServer.getExamples("D");
 
         assertTrue(derivedData != null);

Modified: pig/branches/branch-0.9/test/org/apache/pig/test/TestLogicalPlanBuilder.java
URL: http://svn.apache.org/viewvc/pig/branches/branch-0.9/test/org/apache/pig/test/TestLogicalPlanBuilder.java?rev=1102842&r1=1102841&r2=1102842&view=diff
==============================================================================
--- pig/branches/branch-0.9/test/org/apache/pig/test/TestLogicalPlanBuilder.java (original)
+++ pig/branches/branch-0.9/test/org/apache/pig/test/TestLogicalPlanBuilder.java Fri May 13 18:12:38 2011
@@ -884,7 +884,7 @@ public class TestLogicalPlanBuilder {
     @Test
     public void testQuery75() throws Exception {
         String q = "a = union (load 'a'), (load 'b'), (load 'c');";
-        buildPlan( q + "b = foreach a {generate $0;} parallel 10;");
+        buildPlan( q + "b = foreach a {generate $0;};");
     }
     
     @Test
@@ -2030,6 +2030,21 @@ public class TestLogicalPlanBuilder {
     }
     
     @Test
+    public void testMissingSemicolon() throws Exception {
+        try {
+            String query = "A = load '1.txt' \n" +
+                           "B = load '2.txt' as (b0:int, b1:int);\n" +
+                           "C = union A, B;\n" +
+                           "store C into 'output';";
+            buildPlan( query );
+        } catch (AssertionFailedError e) {
+            Assert.assertTrue(e.getMessage().contains("mismatched input 'B' expecting SEMI_COLON"));
+           return;
+        }
+        Assert.fail("An exception was expected but did not occur");
+    }
+    
+    @Test
     public void testCogroupByIncompatibleSchemaFailure() throws Exception {
         boolean exceptionThrown = false;
         try {