Author: daijy
Date: Mon Jul 19 17:08:36 2010
New Revision: 965558

URL: http://svn.apache.org/viewvc?rev=965558&view=rev
Log:
PIG-1493: Column Pruner throw exception "inconsistent pruning"

Modified:
    hadoop/pig/branches/branch-0.7/CHANGES.txt
    
hadoop/pig/branches/branch-0.7/src/org/apache/pig/impl/logicalLayer/ColumnPruner.java
    hadoop/pig/branches/branch-0.7/test/org/apache/pig/test/TestPruneColumn.java

Modified: hadoop/pig/branches/branch-0.7/CHANGES.txt
URL: 
http://svn.apache.org/viewvc/hadoop/pig/branches/branch-0.7/CHANGES.txt?rev=965558&r1=965557&r2=965558&view=diff
==============================================================================
--- hadoop/pig/branches/branch-0.7/CHANGES.txt (original)
+++ hadoop/pig/branches/branch-0.7/CHANGES.txt Mon Jul 19 17:08:36 2010
@@ -198,6 +198,8 @@ OPTIMIZATIONS
 
 BUG FIXES
 
+PIG-1493: Column Pruner throw exception "inconsistent pruning" (daijy)
+
 PIG-1490: Make Pig storers work with remote HDFS in secure mode (rding)
 
 PIG-1484: BinStorage should support comma seperated path (daijy)

Modified: 
hadoop/pig/branches/branch-0.7/src/org/apache/pig/impl/logicalLayer/ColumnPruner.java
URL: 
http://svn.apache.org/viewvc/hadoop/pig/branches/branch-0.7/src/org/apache/pig/impl/logicalLayer/ColumnPruner.java?rev=965558&r1=965557&r2=965558&view=diff
==============================================================================
--- 
hadoop/pig/branches/branch-0.7/src/org/apache/pig/impl/logicalLayer/ColumnPruner.java
 (original)
+++ 
hadoop/pig/branches/branch-0.7/src/org/apache/pig/impl/logicalLayer/ColumnPruner.java
 Mon Jul 19 17:08:36 2010
@@ -134,19 +134,11 @@ public class ColumnPruner extends LOVisi
                             break;
                         for (Pair<Integer, Integer> relevantField: 
relevantFields.getFields())
                         {
+                            // If any of the input column is pruned, prune 
this output column
                             if (columnsPruned.contains(relevantField))
                             {
                                 columnPruned = true;
-                            }
-                            else {
-                                // For union, inconsistent pruning is possible 
(See PIG-1146)
-                                // We shall allow inconsistent pruning for 
union, and the pruneColumns method
-                                // in LOUnion will handle this inconsistency
-                                if (!(lOp instanceof LOUnion) && 
columnPruned==true) {
-                                    int errCode = 2185;
-                                    String msg = "Column $"+i+" of "+lOp+" 
inconsistent pruning";
-                                    throw new OptimizerException(msg, errCode, 
PigException.BUG);
-                                }
+                                break;
                             }
                         }
                     }

Modified: 
hadoop/pig/branches/branch-0.7/test/org/apache/pig/test/TestPruneColumn.java
URL: 
http://svn.apache.org/viewvc/hadoop/pig/branches/branch-0.7/test/org/apache/pig/test/TestPruneColumn.java?rev=965558&r1=965557&r2=965558&view=diff
==============================================================================
--- 
hadoop/pig/branches/branch-0.7/test/org/apache/pig/test/TestPruneColumn.java 
(original)
+++ 
hadoop/pig/branches/branch-0.7/test/org/apache/pig/test/TestPruneColumn.java 
Mon Jul 19 17:08:36 2010
@@ -1878,4 +1878,24 @@ public class TestPruneColumn extends Tes
                 "No map keys pruned for A"}));
     }
 
+    // See PIG-1493
+    @Test
+    public void testInconsistentPruning() throws Exception {
+        pigServer.registerQuery("A = load '"+ 
Util.generateURI(tmpFile1.toString(), pigServer.getPigContext()) + "' AS 
(a0:chararray, a1:chararray, a2);");
+        pigServer.registerQuery("B = foreach A generate CONCAT(a0,a1) as b0, 
a0, a2;");
+        pigServer.registerQuery("C = foreach B generate a0, a2;");
+        Iterator<Tuple> iter = pigServer.openIterator("C");
+
+        assertTrue(iter.hasNext());
+        Tuple t = iter.next();
+        assertTrue(t.toString().equals("(1,3)"));
+        
+        assertTrue(iter.hasNext());
+        t = iter.next();
+        assertTrue(t.toString().equals("(2,2)"));
+
+        assertTrue(checkLogFileMessage(new String[]{"Columns pruned for A: $1",
+                "No map keys pruned for A"}));
+    }
+
 }


Reply via email to