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 2012/03/02 00:40:13 UTC

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

Author: daijy
Date: Thu Mar  1 23:40:12 2012
New Revision: 1295994

URL: http://svn.apache.org/viewvc?rev=1295994&view=rev
Log:
PIG-2509: Util.getSchemaFromString fails with java.lang.NullPointerException when a tuple in a bag has no name (as when used in MongoStorage UDF)

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

Modified: pig/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/pig/trunk/CHANGES.txt?rev=1295994&r1=1295993&r2=1295994&view=diff
==============================================================================
--- pig/trunk/CHANGES.txt (original)
+++ pig/trunk/CHANGES.txt Thu Mar  1 23:40:12 2012
@@ -265,6 +265,8 @@ PIG-2228: support partial aggregation in
 
 BUG FIXES
 
+PIG-2509: Util.getSchemaFromString fails with java.lang.NullPointerException when a tuple in a bag has no name (as when used in MongoStorage UDF) (jcoveney via daijy)
+
 PIG-2559: Embedded pig in python; invoking sys.exit(0) causes script failure (vivekp via daijy)
 
 PIG-2530: Reusing alias name in nested foreach causes incorrect results (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=1295994&r1=1295993&r2=1295994&view=diff
==============================================================================
--- pig/trunk/src/org/apache/pig/parser/QueryParser.g (original)
+++ pig/trunk/src/org/apache/pig/parser/QueryParser.g Thu Mar  1 23:40:12 2012
@@ -315,7 +315,9 @@ tuple_type : TUPLE? LEFT_PAREN field_def
           -> ^( TUPLE_TYPE field_def_list? )
 ;
 
-bag_type : BAG? LEFT_CURLY ( ( identifier COLON )? tuple_type )? RIGHT_CURLY
+bag_type : BAG? LEFT_CURLY ( null_keyword COLON tuple_type? ) RIGHT_CURLY
+        -> ^( BAG_TYPE tuple_type? )
+         | BAG? LEFT_CURLY ( ( identifier COLON )? tuple_type )? RIGHT_CURLY
         -> ^( BAG_TYPE identifier? tuple_type? )
 ;
 

Modified: pig/trunk/test/org/apache/pig/test/TestSchema.java
URL: http://svn.apache.org/viewvc/pig/trunk/test/org/apache/pig/test/TestSchema.java?rev=1295994&r1=1295993&r2=1295994&view=diff
==============================================================================
--- pig/trunk/test/org/apache/pig/test/TestSchema.java (original)
+++ pig/trunk/test/org/apache/pig/test/TestSchema.java Thu Mar  1 23:40:12 2012
@@ -882,7 +882,8 @@ public class TestSchema {
             "a:double,b:float,t:tuple(x:int,b:bag{t:tuple(a:int,b:float,c:double,x:tuple(z:bag{r:tuple(z:bytearray)}))},z:bytearray)",
             "a,b,t:tuple(x,b:bag{t:tuple(a,b,c,x:tuple(z:bag{r:tuple(z)}))},z)",
             "a:bag{t:tuple(a:bag{t:tuple(a:bag{t:tuple(a:bag{t:tuple(a:bag{t:tuple(a:bag{t:tuple(a:int,b:float)})})})})})}",
-            "a:bag{}"
+            "a:bag{}",
+            "b:{null:(a:int)}"
         };
         for (String schemaString : schemaStrings) {
             Schema s1 = Utils.getSchemaFromString(schemaString);