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

svn commit: r1384276 - in /pig/trunk: CHANGES.txt src/org/apache/pig/parser/AliasMasker.g test/org/apache/pig/test/TestMacroExpansion.java

Author: gates
Date: Thu Sep 13 11:23:08 2012
New Revision: 1384276

URL: http://svn.apache.org/viewvc?rev=1384276&view=rev
Log:
PIG-2887 Macro cannot handle negative number

Modified:
    pig/trunk/CHANGES.txt
    pig/trunk/src/org/apache/pig/parser/AliasMasker.g
    pig/trunk/test/org/apache/pig/test/TestMacroExpansion.java

Modified: pig/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/pig/trunk/CHANGES.txt?rev=1384276&r1=1384275&r2=1384276&view=diff
==============================================================================
--- pig/trunk/CHANGES.txt (original)
+++ pig/trunk/CHANGES.txt Thu Sep 13 11:23:08 2012
@@ -269,6 +269,8 @@ OPTIMIZATIONS
 
 BUG FIXES
 
+PIG-2887: Macro cannot handle negative number (knoguchi via gates)
+
 PIG-2844: ant makepom is misconfigured (julien)
 
 PIG-2896: Pig does not fail anymore if two macros are declared with the same name (julien)

Modified: pig/trunk/src/org/apache/pig/parser/AliasMasker.g
URL: http://svn.apache.org/viewvc/pig/trunk/src/org/apache/pig/parser/AliasMasker.g?rev=1384276&r1=1384275&r2=1384276&view=diff
==============================================================================
--- pig/trunk/src/org/apache/pig/parser/AliasMasker.g (original)
+++ pig/trunk/src/org/apache/pig/parser/AliasMasker.g Thu Sep 13 11:23:08 2012
@@ -564,15 +564,10 @@ const_expr : literal
 literal : scalar | map | bag | tuple
 ;
 
-scalar 
-    : INTEGER
-    | LONGINTEGER
-    | FLOATNUMBER
-    | DOUBLENUMBER
-    | QUOTEDSTRING
-    | NULL
-    | TRUE
-    | FALSE
+scalar : num_scalar | QUOTEDSTRING | NULL | TRUE | FALSE
+;
+
+num_scalar : MINUS? ( INTEGER | LONGINTEGER | FLOATNUMBER | DOUBLENUMBER )
 ;
 
 map 

Modified: pig/trunk/test/org/apache/pig/test/TestMacroExpansion.java
URL: http://svn.apache.org/viewvc/pig/trunk/test/org/apache/pig/test/TestMacroExpansion.java?rev=1384276&r1=1384275&r2=1384276&view=diff
==============================================================================
--- pig/trunk/test/org/apache/pig/test/TestMacroExpansion.java (original)
+++ pig/trunk/test/org/apache/pig/test/TestMacroExpansion.java Thu Sep 13 11:23:08 2012
@@ -1379,6 +1379,17 @@ public class TestMacroExpansion {
         
         verify(macro + script, expected);
     }
+
+    @Test // PIG-2887
+    public void testNegativeNumber() throws Exception {
+        String query = "A = load 'x' as ( u:int, v:long, w:bytearray); " +
+                       "B = filter A by 2 > -1; " ;
+
+        String expected =
+            "macro_mymacro_A_0 = load 'x' as (u:int, v:long, w:bytearray);\n" +
+            "macro_mymacro_B_0 = filter macro_mymacro_A_0 BY (2 > -1);\n" ;
+        testMacro( query, expected );
+    }
     
     @Test
     public void test1() throws Exception {