Return-Path: X-Original-To: apmail-pig-commits-archive@www.apache.org Delivered-To: apmail-pig-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 862C072AF for ; Thu, 14 Jul 2011 16:12:57 +0000 (UTC) Received: (qmail 48254 invoked by uid 500); 14 Jul 2011 16:12:57 -0000 Delivered-To: apmail-pig-commits-archive@pig.apache.org Received: (qmail 48206 invoked by uid 500); 14 Jul 2011 16:12:56 -0000 Mailing-List: contact commits-help@pig.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@pig.apache.org Delivered-To: mailing list commits@pig.apache.org Received: (qmail 48199 invoked by uid 99); 14 Jul 2011 16:12:56 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 14 Jul 2011 16:12:56 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 14 Jul 2011 16:12:53 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 2658423888C2 for ; Thu, 14 Jul 2011 16:12:32 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: commits@pig.apache.org From: thejas@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20110714161232.2658423888C2@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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 itE = pigServer.openIterator("e"); + List 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