Author: daijy
Date: Tue Oct 20 02:18:28 2009
New Revision: 826927

URL: http://svn.apache.org/viewvc?rev=826927&view=rev
Log:
PIG-644: Duplicate column names in foreach do not throw parser error

Modified:
    
hadoop/pig/trunk/src/org/apache/pig/impl/logicalLayer/validators/SchemaAliasVisitor.java
    hadoop/pig/trunk/test/org/apache/pig/test/TestEvalPipeline.java
    hadoop/pig/trunk/test/org/apache/pig/test/TestEvalPipelineLocal.java
    hadoop/pig/trunk/test/org/apache/pig/test/TestJoin.java

Modified: 
hadoop/pig/trunk/src/org/apache/pig/impl/logicalLayer/validators/SchemaAliasVisitor.java
URL: 
http://svn.apache.org/viewvc/hadoop/pig/trunk/src/org/apache/pig/impl/logicalLayer/validators/SchemaAliasVisitor.java?rev=826927&r1=826926&r2=826927&view=diff
==============================================================================
--- 
hadoop/pig/trunk/src/org/apache/pig/impl/logicalLayer/validators/SchemaAliasVisitor.java
 (original)
+++ 
hadoop/pig/trunk/src/org/apache/pig/impl/logicalLayer/validators/SchemaAliasVisitor.java
 Tue Oct 20 02:18:28 2009
@@ -57,6 +57,8 @@
                     for (int j = i + 1; j < schema.size(); j++) {
                         if (schema.getField(i) != null
                                 && schema.getField(j) != null
+                                && schema.getField(i).alias != null 
+                                && schema.getField(j).alias != null
                                 && schema.getField(i).alias.equals(schema
                                         .getField(j).alias)) {
                             int errCode = 1108;

Modified: hadoop/pig/trunk/test/org/apache/pig/test/TestEvalPipeline.java
URL: 
http://svn.apache.org/viewvc/hadoop/pig/trunk/test/org/apache/pig/test/TestEvalPipeline.java?rev=826927&r1=826926&r2=826927&view=diff
==============================================================================
--- hadoop/pig/trunk/test/org/apache/pig/test/TestEvalPipeline.java (original)
+++ hadoop/pig/trunk/test/org/apache/pig/test/TestEvalPipeline.java Tue Oct 20 
02:18:28 2009
@@ -574,7 +574,7 @@
                 "as (b, t2, m);",
                 "p = load '" + output +"' using BinStorage() ;"};
         // the corresponding generate statements
-        String[] generates = {"q = foreach p generate COUNT(b), t2.a, t2.b, 
m#'key1', m#'key2', b;",
+        String[] generates = {"q = foreach p generate COUNT(b), t2.a, t2.b as 
t2b, m#'key1', m#'key2', b;",
                 "q = foreach p generate COUNT(b), t2.$0, t2.$1, m#'key1', 
m#'key2', b;",
                 "q = foreach p generate COUNT($0), $1.$0, $1.$1, $2#'key1', 
$2#'key2', $0;"};
         

Modified: hadoop/pig/trunk/test/org/apache/pig/test/TestEvalPipelineLocal.java
URL: 
http://svn.apache.org/viewvc/hadoop/pig/trunk/test/org/apache/pig/test/TestEvalPipelineLocal.java?rev=826927&r1=826926&r2=826927&view=diff
==============================================================================
--- hadoop/pig/trunk/test/org/apache/pig/test/TestEvalPipelineLocal.java 
(original)
+++ hadoop/pig/trunk/test/org/apache/pig/test/TestEvalPipelineLocal.java Tue 
Oct 20 02:18:28 2009
@@ -587,7 +587,7 @@
                 "as (b, t2, m);",
                 "p = load '" + output +"' using BinStorage() ;"};
         // the corresponding generate statements
-        String[] generates = {"q = foreach p generate COUNT(b), t2.a, t2.b, 
m#'key1', m#'key2', b;",
+        String[] generates = {"q = foreach p generate COUNT(b), t2.a, t2.b as 
t2b, m#'key1', m#'key2', b;",
                 "q = foreach p generate COUNT(b), t2.$0, t2.$1, m#'key1', 
m#'key2', b;",
                 "q = foreach p generate COUNT($0), $1.$0, $1.$1, $2#'key1', 
$2#'key2', $0;"};
         

Modified: hadoop/pig/trunk/test/org/apache/pig/test/TestJoin.java
URL: 
http://svn.apache.org/viewvc/hadoop/pig/trunk/test/org/apache/pig/test/TestJoin.java?rev=826927&r1=826926&r2=826927&view=diff
==============================================================================
--- hadoop/pig/trunk/test/org/apache/pig/test/TestJoin.java (original)
+++ hadoop/pig/trunk/test/org/apache/pig/test/TestJoin.java Tue Oct 20 02:18:28 
2009
@@ -176,7 +176,7 @@
             String script = "a = load '"+ firstInput +"' as (i:int, j:int); " +
                     "b = load '"+ secondInput +"' as (k:int, l:chararray); " +
                     "c = join a by $0, b by $0;" +
-                    "d = foreach c generate i,j,k,l,a::i,a::j,b::k,b::l;";
+                    "d = foreach c generate i,j,k,l,a::i as ai,a::j as aj,b::k 
as bk,b::l as bl;";
             Util.registerMultiLineQuery(pigServer, script);
             Iterator<Tuple> it = pigServer.openIterator("d");
             assertEquals(true, it.hasNext());
@@ -187,7 +187,7 @@
             script = "a = load '"+ firstInput +"' as (i:int, j:int); " +
             "b = load '"+ secondInput +"' as (i:int, l:chararray); " +
             "c = join a by $0, b by $0;" +
-            "d = foreach c generate i,j,l,a::i,a::j,b::i,b::l;";
+            "d = foreach c generate i,j,l,a::i as ai,a::j as aj,b::i as 
bi,b::l as bl;";
             boolean exceptionThrown = false;
             try{
                 Util.registerMultiLineQuery(pigServer, script);
@@ -202,7 +202,7 @@
             script = "a = load '"+ firstInput +"' as (i:int, j:int); " +
             "b = load '"+ secondInput +"' as (i:int, l:chararray); " +
             "c = join a by $0, b by $0;" +
-            "d = foreach c generate a::i,j,b::i,l,a::i,a::j,b::i,b::l;";
+            "d = foreach c generate a::i as ai1,j,b::i as bi1,l,a::i as 
ai2,a::j as aj2,b::i as bi3,b::l as bl3;";
             Util.registerMultiLineQuery(pigServer, script);
             it = pigServer.openIterator("d");
             assertEquals(true, it.hasNext());


Reply via email to