pig-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From the...@apache.org
Subject svn commit: r1146777 - in /pig/trunk: CHANGES.txt src/org/apache/pig/parser/QueryParser.g test/org/apache/pig/test/TestLimitVariable.java test/org/apache/pig/test/TestSample.java
Date Thu, 14 Jul 2011 16:12:32 GMT
Author: thejas
Date: Thu Jul 14 16:12:31 2011
New Revision: 1146777

URL: http://svn.apache.org/viewvc?rev=1146777&view=rev
Log:
PIG-2156: Limit/Sample with variable does not work if the expression starts
 with an integer/double (azaroth via thejas)


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

Modified: pig/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/pig/trunk/CHANGES.txt?rev=1146777&r1=1146776&r2=1146777&view=diff
==============================================================================
--- pig/trunk/CHANGES.txt (original)
+++ pig/trunk/CHANGES.txt Thu Jul 14 16:12:31 2011
@@ -75,6 +75,9 @@ PIG-2011: Speed up TestTypedMap.java (dv
 
 BUG FIXES
 
+PIG-2156: Limit/Sample with variable does not work if the expression starts 
+ with an integer/double (azaroth via thejas)
+
 PIG-2130: Piggybank:MultiStorage is not compressing output files (vivekp via daijy)
 
 PIG-2147: Support nested tags for XMLLoader (vivekp via 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=1146777&r1=1146776&r2=1146777&view=diff
==============================================================================
--- pig/trunk/src/org/apache/pig/parser/QueryParser.g (original)
+++ pig/trunk/src/org/apache/pig/parser/QueryParser.g Thu Jul 14 16:12:31 2011
@@ -464,10 +464,10 @@ neg_expr : MINUS cast_expr
         -> ^( NEG cast_expr )
 ;
 
-limit_clause : LIMIT^ rel ( INTEGER | LONGINTEGER | expr )
+limit_clause : LIMIT^ rel ( (INTEGER SEMI_COLON) => INTEGER | (LONGINTEGER SEMI_COLON)
=> LONGINTEGER | expr )
 ;
 
-sample_clause : SAMPLE^ rel ( DOUBLENUMBER | expr )
+sample_clause : SAMPLE^ rel ( (DOUBLENUMBER SEMI_COLON) => DOUBLENUMBER | expr )
 ;
 
 order_clause : ORDER^ rel BY! order_by_clause ( USING! func_clause )?
@@ -588,7 +588,7 @@ nested_sort : ORDER^ nested_op_input BY!
 nested_distinct : DISTINCT^ nested_op_input
 ;
 
-nested_limit : LIMIT^ nested_op_input ( INTEGER | expr )
+nested_limit : LIMIT^ nested_op_input ( (INTEGER SEMI_COLON) => INTEGER | expr )
 ;
 
 nested_cross : CROSS^ nested_op_input_list

Modified: pig/trunk/test/org/apache/pig/test/TestLimitVariable.java
URL: http://svn.apache.org/viewvc/pig/trunk/test/org/apache/pig/test/TestLimitVariable.java?rev=1146777&r1=1146776&r2=1146777&view=diff
==============================================================================
--- pig/trunk/test/org/apache/pig/test/TestLimitVariable.java (original)
+++ pig/trunk/test/org/apache/pig/test/TestLimitVariable.java Thu Jul 14 16:12:31 2011
@@ -99,6 +99,23 @@ public class TestLimitVariable {
         Util.checkQueryOutputs(itE, expectedResE);
     }
     
+    @Test
+    public void testLimitVariable3() throws IOException {
+        String query =
+            "a = load '" + inputFile.getName() + "' ;" +
+            "b = group a all;" + 
+            "c = foreach b generate COUNT(a) as sum;" + 
+            "d = order a by $0 ASC;" + 
+            "e = limit d 1 * c.sum;" // return all the tuples, test for PIG-2156
+            ;
+
+        Util.registerMultiLineQuery(pigServer, query);
+        Iterator<Tuple> itE = pigServer.openIterator("e");
+        List<Tuple> expectedResE = Util.getTuplesFromConstantTupleStrings(new String[]
{
+                "(1,11)", "(2,3)", "(3,10)", "(4,11)", "(5,10)", "(6,15)" });
+        Util.checkQueryOutputs(itE, expectedResE);
+    }
+
     @Test(expected=FrontendException.class)
     public void testLimitVariableException1() throws Throwable {
         String query = 

Modified: pig/trunk/test/org/apache/pig/test/TestSample.java
URL: http://svn.apache.org/viewvc/pig/trunk/test/org/apache/pig/test/TestSample.java?rev=1146777&r1=1146776&r2=1146777&view=diff
==============================================================================
--- pig/trunk/test/org/apache/pig/test/TestSample.java (original)
+++ pig/trunk/test/org/apache/pig/test/TestSample.java Thu Jul 14 16:12:31 2011
@@ -120,7 +120,7 @@ public class TestSample {
         verify("a = LOAD '" + tmpfilepath + "'; " +
                 "b = GROUP a all;" +
                 "c = FOREACH b GENERATE COUNT(a) AS count;" +
-                "myid = SAMPLE a (c.count / c.count);", DATALEN, DATALEN);
+                "myid = SAMPLE a 1.0 * (c.count / c.count) PARALLEL 2;", DATALEN, DATALEN);
// test for PIG-2156
     }
     
     @Test



Mime
View raw message