You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pig.apache.org by da...@apache.org on 2011/09/23 19:31:53 UTC

svn commit: r1174900 - in /pig/trunk: CHANGES.txt src/org/apache/pig/parser/QueryParser.g test/org/apache/pig/parser/TestLogicalPlanGenerator.java

Author: daijy
Date: Fri Sep 23 17:31:53 2011
New Revision: 1174900

URL: http://svn.apache.org/viewvc?rev=1174900&view=rev
Log:
PIG-2261: Restore support for parenthesis in Pig 0.9

Modified:
    pig/trunk/CHANGES.txt
    pig/trunk/src/org/apache/pig/parser/QueryParser.g
    pig/trunk/test/org/apache/pig/parser/TestLogicalPlanGenerator.java

Modified: pig/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/pig/trunk/CHANGES.txt?rev=1174900&r1=1174899&r2=1174900&view=diff
==============================================================================
--- pig/trunk/CHANGES.txt (original)
+++ pig/trunk/CHANGES.txt Fri Sep 23 17:31:53 2011
@@ -257,6 +257,8 @@ PIG-2221: Couldnt find documentation for
 
 BUG FIXES
 
+PIG-2261: Restore support for parenthesis in Pig 0.9 (rding via daijy)
+
 PIG-2238: Pig 0.9 error message not useful as compared to 0.8 (daijy)
 
 PIG-2286: Using COR function in Piggybank results in ERROR 2018: Internal error. Unable to introduce the combiner for optimization (daijy)

Modified: pig/trunk/src/org/apache/pig/parser/QueryParser.g
URL: http://svn.apache.org/viewvc/pig/trunk/src/org/apache/pig/parser/QueryParser.g?rev=1174900&r1=1174899&r2=1174900&view=diff
==============================================================================
--- pig/trunk/src/org/apache/pig/parser/QueryParser.g (original)
+++ pig/trunk/src/org/apache/pig/parser/QueryParser.g Fri Sep 23 17:31:53 2011
@@ -161,7 +161,7 @@ inline_statement : inline_clause SEMI_CO
 split_statement : split_clause SEMI_COLON!
 ;
 
-general_statement : ( alias EQUAL )? op_clause parallel_clause? SEMI_COLON 
+general_statement : ( alias EQUAL )? (op_clause parallel_clause? | LEFT_PAREN op_clause parallel_clause? RIGHT_PAREN) SEMI_COLON 
                  -> ^( STATEMENT alias? op_clause parallel_clause? )
 ;
 
@@ -180,7 +180,8 @@ foreach_complex_statement : ( alias EQUA
                          -> ^( STATEMENT alias? foreach_clause_complex )
 ;
 
-foreach_simple_statement : ( alias EQUAL )? foreach_clause_simple parallel_clause? SEMI_COLON
+foreach_simple_statement : ( alias EQUAL )? (foreach_clause_simple parallel_clause? 
+                                                | LEFT_PAREN foreach_clause_simple parallel_clause? RIGHT_PAREN) SEMI_COLON
                         -> ^( STATEMENT alias? foreach_clause_simple parallel_clause? )
 ;
 

Modified: pig/trunk/test/org/apache/pig/parser/TestLogicalPlanGenerator.java
URL: http://svn.apache.org/viewvc/pig/trunk/test/org/apache/pig/parser/TestLogicalPlanGenerator.java?rev=1174900&r1=1174899&r2=1174900&view=diff
==============================================================================
--- pig/trunk/test/org/apache/pig/parser/TestLogicalPlanGenerator.java (original)
+++ pig/trunk/test/org/apache/pig/parser/TestLogicalPlanGenerator.java Fri Sep 23 17:31:53 2011
@@ -253,6 +253,52 @@ public class TestLogicalPlanGenerator {
     }
     
     @Test
+    public void test22() {
+        String query = "A = (load 'x' as (u, v));\n" +
+                       "B = (group (foreach A generate $0 parallel 5) all);";
+        generateLogicalPlan( query );
+    }
+    
+    @Test
+    public void test23() {
+        String query = "a = (load 'x1' using PigStorage() as (name, age, gpa));" +
+                       "b = (group a all);" +
+                       "c = (foreach b generate AVG(a.age) as avg); " +
+                       "d = (load 'x2' using PigStorage() as (name, age, registration, contributions));" +
+                       "e = (group d all);" +
+                       "f = (foreach e generate AVG(d.age) as avg);" +
+                       "y = (foreach a generate age/c.avg, age/f.avg);" +
+                       "store y into 'y';";
+        generateLogicalPlan( query );
+    }
+    
+    @Test
+    public void test24() {
+        String query = "a = (load 'x1' using PigStorage() as (name, age:int, gpa));" +
+                       "b = (load 'x2' as (name, age, registration, contributions));" +
+                       "e = (cogroup a by name, b by name parallel 8);" +
+                       "f = (foreach e generate group,  SUM(a.age) as s);" +
+                       "g = (filter f by s>0);" +
+                       "(store g into 'y');";
+        generateLogicalPlan( query );
+    }
+    
+    @Test
+    public void test25() {
+        String query = "A = (load 'x' as ( u:int, v:long, w:bytearray)); " + 
+                       "B = (distinct A partition by org.apache.pig.Identity); " +
+                       "C = (sample B 0.49); " +
+                       "D = (order C by $0, $1); " +
+                       "E = (load 'y' as (d1, d2)); " +
+                       "F = (union onschema D, E); " +
+                       "G = (load 'z' as (g1:int, g2:tuple(g21, g22))); " +
+                       "H = (cross F, G); " +
+                       "split H into I if 10 > 5, J if 'world' eq 'hello', K if 77 <= 200; " +
+                       "L = (store J into 'output');";
+        generateLogicalPlan( query );
+    }
+    
+    @Test
     public void testFilter() {
         String query = "A = load 'x' as ( u:int, v:long, w:bytearray); " + 
                        "B = filter A by 2 > 1;\n" +