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 1DEC090A5 for ; Fri, 16 Dec 2011 03:37:14 +0000 (UTC) Received: (qmail 33550 invoked by uid 500); 16 Dec 2011 03:37:13 -0000 Delivered-To: apmail-pig-commits-archive@pig.apache.org Received: (qmail 33530 invoked by uid 500); 16 Dec 2011 03:37:13 -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 33521 invoked by uid 99); 16 Dec 2011 03:37:11 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 16 Dec 2011 03:37:11 +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; Fri, 16 Dec 2011 03:37:04 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 2CF1623889E2 for ; Fri, 16 Dec 2011 03:36:44 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1215034 - in /pig/branches/branch-0.10: ./ src/org/apache/pig/parser/ test/org/apache/pig/test/ Date: Fri, 16 Dec 2011 03:36:43 -0000 To: commits@pig.apache.org From: dvryaboy@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20111216033644.2CF1623889E2@eris.apache.org> Author: dvryaboy Date: Fri Dec 16 03:36:43 2011 New Revision: 1215034 URL: http://svn.apache.org/viewvc?rev=1215034&view=rev Log: PIG-2427: getSchemaFromString throws away the name of the tuple that is in a bag Modified: pig/branches/branch-0.10/CHANGES.txt pig/branches/branch-0.10/src/org/apache/pig/parser/AliasMasker.g pig/branches/branch-0.10/src/org/apache/pig/parser/AstValidator.g pig/branches/branch-0.10/src/org/apache/pig/parser/LogicalPlanGenerator.g pig/branches/branch-0.10/src/org/apache/pig/parser/QueryParser.g pig/branches/branch-0.10/test/org/apache/pig/test/TestSchema.java Modified: pig/branches/branch-0.10/CHANGES.txt URL: http://svn.apache.org/viewvc/pig/branches/branch-0.10/CHANGES.txt?rev=1215034&r1=1215033&r2=1215034&view=diff ============================================================================== --- pig/branches/branch-0.10/CHANGES.txt (original) +++ pig/branches/branch-0.10/CHANGES.txt Fri Dec 16 03:36:43 2011 @@ -156,6 +156,8 @@ PIG-2228: support partial aggregation in BUG FIXES +PIG-2427: getSchemaFromString throws away the name of the tuple that is in a bag (jcoveney via dvryaboy) + PIG-2425: Aggregate Warning does not work as expected on Embedding Pig in Java 0.9.1 (prkommireddi via thejas) PIG-2331: BinStorage in LOAD statement failing when input has curly braces (xutingz via thejas) Modified: pig/branches/branch-0.10/src/org/apache/pig/parser/AliasMasker.g URL: http://svn.apache.org/viewvc/pig/branches/branch-0.10/src/org/apache/pig/parser/AliasMasker.g?rev=1215034&r1=1215033&r2=1215034&view=diff ============================================================================== --- pig/branches/branch-0.10/src/org/apache/pig/parser/AliasMasker.g (original) +++ pig/branches/branch-0.10/src/org/apache/pig/parser/AliasMasker.g Fri Dec 16 03:36:43 2011 @@ -209,7 +209,7 @@ tuple_type ; bag_type - : ^( BAG_TYPE tuple_type? ) + : ^( BAG_TYPE IDENTIFIER? tuple_type? ) ; map_type : ^( MAP_TYPE type? ) Modified: pig/branches/branch-0.10/src/org/apache/pig/parser/AstValidator.g URL: http://svn.apache.org/viewvc/pig/branches/branch-0.10/src/org/apache/pig/parser/AstValidator.g?rev=1215034&r1=1215033&r2=1215034&view=diff ============================================================================== --- pig/branches/branch-0.10/src/org/apache/pig/parser/AstValidator.g (original) +++ pig/branches/branch-0.10/src/org/apache/pig/parser/AstValidator.g Fri Dec 16 03:36:43 2011 @@ -209,7 +209,7 @@ simple_type : BOOLEAN | INT | LONG | FLO tuple_type : ^( TUPLE_TYPE field_def_list? ) ; -bag_type : ^( BAG_TYPE tuple_type? ) +bag_type : ^( BAG_TYPE IDENTIFIER? tuple_type? ) ; map_type : ^( MAP_TYPE type? ) Modified: pig/branches/branch-0.10/src/org/apache/pig/parser/LogicalPlanGenerator.g URL: http://svn.apache.org/viewvc/pig/branches/branch-0.10/src/org/apache/pig/parser/LogicalPlanGenerator.g?rev=1215034&r1=1215033&r2=1215034&view=diff ============================================================================== --- pig/branches/branch-0.10/src/org/apache/pig/parser/LogicalPlanGenerator.g (original) +++ pig/branches/branch-0.10/src/org/apache/pig/parser/LogicalPlanGenerator.g Fri Dec 16 03:36:43 2011 @@ -375,14 +375,14 @@ tuple_type returns[LogicalSchema logical ; bag_type returns[LogicalSchema logicalSchema] - : ^( BAG_TYPE tuple_type? ) + : ^( BAG_TYPE IDENTIFIER? tuple_type? ) { if ($tuple_type.logicalSchema!=null && $tuple_type.logicalSchema.size()==1 && $tuple_type.logicalSchema.getField(0).type==DataType.TUPLE) { $logicalSchema = $tuple_type.logicalSchema; } else { LogicalSchema s = new LogicalSchema(); - s.addField(new LogicalFieldSchema(null, $tuple_type.logicalSchema, DataType.TUPLE)); + s.addField(new LogicalFieldSchema($IDENTIFIER.text, $tuple_type.logicalSchema, DataType.TUPLE)); $logicalSchema = s; } } Modified: pig/branches/branch-0.10/src/org/apache/pig/parser/QueryParser.g URL: http://svn.apache.org/viewvc/pig/branches/branch-0.10/src/org/apache/pig/parser/QueryParser.g?rev=1215034&r1=1215033&r2=1215034&view=diff ============================================================================== --- pig/branches/branch-0.10/src/org/apache/pig/parser/QueryParser.g (original) +++ pig/branches/branch-0.10/src/org/apache/pig/parser/QueryParser.g Fri Dec 16 03:36:43 2011 @@ -313,7 +313,7 @@ tuple_type : TUPLE? LEFT_PAREN field_def ; bag_type : BAG? LEFT_CURLY ( ( identifier COLON )? tuple_type )? RIGHT_CURLY - -> ^( BAG_TYPE tuple_type? ) + -> ^( BAG_TYPE identifier? tuple_type? ) ; map_type : MAP? LEFT_BRACKET type? RIGHT_BRACKET Modified: pig/branches/branch-0.10/test/org/apache/pig/test/TestSchema.java URL: http://svn.apache.org/viewvc/pig/branches/branch-0.10/test/org/apache/pig/test/TestSchema.java?rev=1215034&r1=1215033&r2=1215034&view=diff ============================================================================== --- pig/branches/branch-0.10/test/org/apache/pig/test/TestSchema.java (original) +++ pig/branches/branch-0.10/test/org/apache/pig/test/TestSchema.java Fri Dec 16 03:36:43 2011 @@ -694,7 +694,7 @@ public class TestSchema { LogicalSchema ls1 = Utils.parseSchema("a:{t:(a0:int, a1:int)}"); LogicalSchema ls2 = Utils.parseSchema("b:{t:(b0:int, b1:int)}"); LogicalSchema ls3 = LogicalSchema.merge(ls1, ls2, MergeMode.LoadForEach); - Assert.assertTrue(org.apache.pig.newplan.logical.Util.translateSchema(ls3).toString().equals("{a: {(a0: int,a1: int)}}")); + Assert.assertTrue(org.apache.pig.newplan.logical.Util.translateSchema(ls3).toString().equals("{a: {t: (a0: int,a1: int)}}")); } @Test @@ -865,4 +865,30 @@ public class TestSchema { Schema s2 = Schema.getPigSchema(new ResourceSchema(s1)); Assert.assertTrue(s1.equals(s2)); } + + @Test + public void testGetStringFromSchema() throws ParserException { + String[] schemaStrings = { + "a:int", + "a:long", + "a:chararray", + "a:double", + "a:float", + "a:bytearray", + "b:bag{tuple(x:int,y:int,z:int)}", + "b:bag{t:tuple(x:int,y:int,z:int)}", + "a:int,b:chararray,c:Map[int]", + "a:double,b:float,t:tuple(x:int,y:double,z:bytearray)", + "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{}" + }; + for (String schemaString : schemaStrings) { + Schema s1 = Utils.getSchemaFromString(schemaString); + String s=s1.toString(); + Schema s2 = Utils.getSchemaFromString(s.substring(1,s.length()-1)); //have to cut out the brackets that surround it + Assert.assertTrue(Schema.equals(s1,s2,false,true)); + } + } }