pig-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From da...@apache.org
Subject svn commit: r1579404 - in /pig/trunk: CHANGES.txt src/org/apache/pig/newplan/logical/relational/LOForEach.java test/org/apache/pig/test/TestEvalPipelineLocal.java
Date Wed, 19 Mar 2014 21:15:38 GMT
Author: daijy
Date: Wed Mar 19 21:15:37 2014
New Revision: 1579404

URL: http://svn.apache.org/r1579404
Log:
PIG-3807: Pig creates wrong schema after dereferencing nested tuple fields with sorts

Modified:
    pig/trunk/CHANGES.txt
    pig/trunk/src/org/apache/pig/newplan/logical/relational/LOForEach.java
    pig/trunk/test/org/apache/pig/test/TestEvalPipelineLocal.java

Modified: pig/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/pig/trunk/CHANGES.txt?rev=1579404&r1=1579403&r2=1579404&view=diff
==============================================================================
--- pig/trunk/CHANGES.txt (original)
+++ pig/trunk/CHANGES.txt Wed Mar 19 21:15:37 2014
@@ -99,6 +99,8 @@ OPTIMIZATIONS
  
 BUG FIXES
 
+PIG-3807: Pig creates wrong schema after dereferencing nested tuple fields with sorts (daijy)
+
 PIG-3813: Rank column is assigned different uids everytime when schema is reset (cheolsoo)
 
 PIG-3815: Hadoop bug causes to pig to fail silently with jar cache (aniket486)

Modified: pig/trunk/src/org/apache/pig/newplan/logical/relational/LOForEach.java
URL: http://svn.apache.org/viewvc/pig/trunk/src/org/apache/pig/newplan/logical/relational/LOForEach.java?rev=1579404&r1=1579403&r2=1579404&view=diff
==============================================================================
--- pig/trunk/src/org/apache/pig/newplan/logical/relational/LOForEach.java (original)
+++ pig/trunk/src/org/apache/pig/newplan/logical/relational/LOForEach.java Wed Mar 19 21:15:37
2014
@@ -61,8 +61,19 @@ public class LOForEach extends LogicalRe
     @Override
     public LogicalSchema getSchema() throws FrontendException {
         List<Operator> ll = innerPlan.getSinks();
-        if (ll != null) {
-            schema = ((LogicalRelationalOperator)ll.get(0)).getSchema();
+        LogicalRelationalOperator generate = null;
+        // We can assume LOGenerate is the only sink of the inner plan, but
+        // only after DanglingNestedNodeRemover. LOForEach.getSchema will be
+        // run before DanglingNestedNodeRemover, so need to make sure we do
+        // get LOGenerate
+        for (Operator op : ll) {
+            if (op instanceof LOGenerate) {
+                generate = (LogicalRelationalOperator)op;
+                break;
+            }
+        }
+        if (generate != null) {
+            schema = generate.getSchema();
         }
         
         return schema;

Modified: pig/trunk/test/org/apache/pig/test/TestEvalPipelineLocal.java
URL: http://svn.apache.org/viewvc/pig/trunk/test/org/apache/pig/test/TestEvalPipelineLocal.java?rev=1579404&r1=1579403&r2=1579404&view=diff
==============================================================================
--- pig/trunk/test/org/apache/pig/test/TestEvalPipelineLocal.java (original)
+++ pig/trunk/test/org/apache/pig/test/TestEvalPipelineLocal.java Wed Mar 19 21:15:37 2014
@@ -1201,4 +1201,19 @@ public class TestEvalPipelineLocal {
         
         Assert.assertFalse(iter.hasNext());
     }
+    
+    // see PIG-3807
+    @Test
+    public void testDanglingNodeWrongSchema() throws Exception{
+        
+        pigServer.registerQuery("d1 = load 'test_data.txt' USING PigStorage() AS (f1: int,
f2: int, f3: int, f4: int);");
+        pigServer.registerQuery("d2 = load 'test_data.txt' USING PigStorage() AS (f1: int,
f2: int, f3: int, f4: int);");
+        pigServer.registerQuery("n1 = foreach (group d1 by f1) {sorted = ORDER d1 by f2;
generate group, flatten(d1.f3) as x3; };");
+        pigServer.registerQuery("n2 = foreach (group d2 by f1) {sorted = ORDER d2 by f2;
generate group, flatten(d2.f3) as q3; };");
+        pigServer.registerQuery("joined = join n1 by x3, n2 by q3;");
+        pigServer.registerQuery("final = foreach joined generate n1::x3;");
+        
+        Schema s = pigServer.dumpSchema("final");
+        Assert.assertEquals(s.toString(), "{n1::x3: int}");
+    }
 }



Mime
View raw message