pig-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From o...@apache.org
Subject svn commit: r696527 - in /incubator/pig/branches/types: CHANGES.txt src/org/apache/pig/impl/logicalLayer/LOForEach.java src/org/apache/pig/impl/logicalLayer/parser/QueryParser.jjt test/org/apache/pig/test/TestLogicalPlanBuilder.java
Date Thu, 18 Sep 2008 00:39:45 GMT
Author: olga
Date: Wed Sep 17 17:39:45 2008
New Revision: 696527

URL: http://svn.apache.org/viewvc?rev=696527&view=rev
Log:
PIG-433: no () for single column alias after flatten

Modified:
    incubator/pig/branches/types/CHANGES.txt
    incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/LOForEach.java
    incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/parser/QueryParser.jjt
    incubator/pig/branches/types/test/org/apache/pig/test/TestLogicalPlanBuilder.java

Modified: incubator/pig/branches/types/CHANGES.txt
URL: http://svn.apache.org/viewvc/incubator/pig/branches/types/CHANGES.txt?rev=696527&r1=696526&r2=696527&view=diff
==============================================================================
--- incubator/pig/branches/types/CHANGES.txt (original)
+++ incubator/pig/branches/types/CHANGES.txt Wed Sep 17 17:39:45 2008
@@ -201,3 +201,5 @@
     (pradeepk via olgan)
 
     PIG-434: short-circuit AND and OR (pradeepk viia olgan)
+
+    PIG-333: allowing no parethesis with single column alias with flatten

Modified: incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/LOForEach.java
URL: http://svn.apache.org/viewvc/incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/LOForEach.java?rev=696527&r1=696526&r2=696527&view=diff
==============================================================================
--- incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/LOForEach.java (original)
+++ incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/LOForEach.java Wed Sep
17 17:39:45 2008
@@ -30,6 +30,7 @@
 import org.apache.pig.impl.plan.OperatorKey;
 import org.apache.pig.impl.plan.PlanVisitor;
 import org.apache.pig.impl.plan.VisitorException;
+import org.apache.pig.impl.logicalLayer.parser.QueryParser ;
 import org.apache.pig.impl.logicalLayer.parser.ParseException;
 import org.apache.pig.data.DataType;
 import org.apache.commons.logging.Log;
@@ -226,6 +227,7 @@
                                         fss.add(newFs);
                                     } else {
                                         for(Schema.FieldSchema ufs: userDefinedSchema.getFields())
{
+                                            QueryParser.SchemaUtils.setFieldSchemaDefaultType(ufs,
DataType.BYTEARRAY);
                                             fss.add(new Schema.FieldSchema(ufs.alias, ufs.schema,
ufs.type));
                                             updateAliasCount(aliases, ufs.alias);
                                         }

Modified: incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/parser/QueryParser.jjt
URL: http://svn.apache.org/viewvc/incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/parser/QueryParser.jjt?rev=696527&r1=696526&r2=696527&view=diff
==============================================================================
--- incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/parser/QueryParser.jjt
(original)
+++ incubator/pig/branches/types/src/org/apache/pig/impl/logicalLayer/parser/QueryParser.jjt
Wed Sep 17 17:39:45 2008
@@ -2260,7 +2260,7 @@
 		{
 			flatten = true;
 		}
-        [ <AS> "(" schema = TupleSchema() ")" ]
+        [ <AS> ( "(" schema = TupleSchema() ")" | fs = FieldSchema() ) ]
 	)
 |	
     (

Modified: incubator/pig/branches/types/test/org/apache/pig/test/TestLogicalPlanBuilder.java
URL: http://svn.apache.org/viewvc/incubator/pig/branches/types/test/org/apache/pig/test/TestLogicalPlanBuilder.java?rev=696527&r1=696526&r2=696527&view=diff
==============================================================================
--- incubator/pig/branches/types/test/org/apache/pig/test/TestLogicalPlanBuilder.java (original)
+++ incubator/pig/branches/types/test/org/apache/pig/test/TestLogicalPlanBuilder.java Wed
Sep 17 17:39:45 2008
@@ -1183,6 +1183,11 @@
         foreach = (LOForEach) lp.getLeaves().get(0);
         assertTrue(foreach.getSchema().equals(getSchemaFromString("name: chararray, age:
int, mycount: long")));
 
+        //the first element in group, i.e., name is renamed as myname 
+        lp = buildPlan("c = foreach b generate flatten(group) as myname, COUNT(a) as mycount;");
+        foreach = (LOForEach) lp.getLeaves().get(0);
+        assertTrue(foreach.getSchema().equals(getSchemaFromString("myname: chararray, age:
int, mycount: long")));
+
         //group is renamed as mygroup
         lp = buildPlan("c = foreach b generate group as mygroup, COUNT(a) as mycount;");
         foreach = (LOForEach) lp.getLeaves().get(0);
@@ -1203,18 +1208,33 @@
         foreach = (LOForEach) lp.getLeaves().get(0);
         assertTrue(foreach.getSchema().equals(getSchemaFromString("mygroup:(name: chararray,
age: int), mycount: long")));
 
-        /*
-        //forcing an wrror by having more elements in the fhe schema
-        lp = buildPlan("c = foreach B generate group as mygroup:(myname, myage, mygpa), COUNT(A)
as mycount;");
-        lp = buildPlan("c = foreach B generate group as mygroup:(myname: int, myage), COUNT(A)
as mycount;");
-        lp = buildPlan("c = foreach B generate group as mygroup:(myname, myage: chararray),
COUNT(A) as mycount;");
-        lp = buildPlan("c = foreach B generate group as mygroup:{t: (myname, myage)}, COUNT(A)
as mycount;");
-        lp = buildPlan("c = foreach B generate flatten(group) as (myname, myage, mygpa),
COUNT(A) as mycount;");
+        //setting the schema of flattened bag that has no schema with the user defined schema
+        buildPlan("c = load 'another_file';");
+        buildPlan("d = cogroup a by $0, c by $0;");
+        lp = buildPlan("e = foreach d generate flatten(DIFF(a, c)) as (x, y, z), COUNT(a)
as mycount;");
+        foreach = (LOForEach) lp.getLeaves().get(0);
+        assertTrue(foreach.getSchema().equals(getSchemaFromString("x: bytearray, y: bytearray,
z: bytearray, mycount: long")));
+
+        //setting the schema of flattened bag that has no schema with the user defined schema
+        buildPlan("c = load 'another_file';");
+        buildPlan("d = cogroup a by $0, c by $0;");
+        lp = buildPlan("e = foreach d generate flatten(DIFF(a, c)) as (x: int, y: float,
z), COUNT(a) as mycount;");
+        foreach = (LOForEach) lp.getLeaves().get(0);
+        assertTrue(foreach.getSchema().equals(getSchemaFromString("x: int, y: float, z: bytearray,
mycount: long")));
 
+        //setting the schema of flattened bag that has no schema with the user defined schema
+        buildPlan("c = load 'another_file';");
+        buildPlan("d = cogroup a by $0, c by $0;");
+        lp = buildPlan("e = foreach d generate flatten(DIFF(a, c)) as x, COUNT(a) as mycount;");
         foreach = (LOForEach) lp.getLeaves().get(0);
+        assertTrue(foreach.getSchema().equals(getSchemaFromString("x: bytearray, mycount:
long")));
 
-        assertTrue(foreach.getSchema().equals(getSchemaFromString()));
-        */
+        //setting the schema of flattened bag that has no schema with the user defined schema
+        buildPlan("c = load 'another_file';");
+        buildPlan("d = cogroup a by $0, c by $0;");
+        lp = buildPlan("e = foreach d generate flatten(DIFF(a, c)) as x: int, COUNT(a) as
mycount;");
+        foreach = (LOForEach) lp.getLeaves().get(0);
+        assertTrue(foreach.getSchema().equals(getSchemaFromString("x: int, mycount: long")));
 
     }
 



Mime
View raw message