Author: knoguchi
Date: Tue Sep 19 18:29:09 2017
New Revision: 1808927

URL: http://svn.apache.org/viewvc?rev=1808927&view=rev
Log:
PIG-5299: PartitionFilterOptimizer failing at compile time (knoguchi)

Modified:
    pig/branches/branch-0.17/CHANGES.txt
    pig/branches/branch-0.17/src/org/apache/pig/newplan/FilterExtractor.java
    
pig/branches/branch-0.17/test/org/apache/pig/test/TestNewPartitionFilterPushDown.java

Modified: pig/branches/branch-0.17/CHANGES.txt
URL: 
http://svn.apache.org/viewvc/pig/branches/branch-0.17/CHANGES.txt?rev=1808927&r1=1808926&r2=1808927&view=diff
==============================================================================
--- pig/branches/branch-0.17/CHANGES.txt (original)
+++ pig/branches/branch-0.17/CHANGES.txt Tue Sep 19 18:29:09 2017
@@ -28,6 +28,8 @@ OPTIMIZATIONS
  
 BUG FIXES
 
+PIG-5299: PartitionFilterOptimizer failing at compile time (knoguchi)
+
 PIG-5254: Hit Ctrl-D to quit grunt shell fail (wjqian via daijy)
 
 PIG-4548: Records Lost With Specific Combination of Commands and Streaming 
Function (knoguchi)

Modified: 
pig/branches/branch-0.17/src/org/apache/pig/newplan/FilterExtractor.java
URL: 
http://svn.apache.org/viewvc/pig/branches/branch-0.17/src/org/apache/pig/newplan/FilterExtractor.java?rev=1808927&r1=1808926&r2=1808927&view=diff
==============================================================================
--- pig/branches/branch-0.17/src/org/apache/pig/newplan/FilterExtractor.java 
(original)
+++ pig/branches/branch-0.17/src/org/apache/pig/newplan/FilterExtractor.java 
Tue Sep 19 18:29:09 2017
@@ -334,7 +334,12 @@ public abstract class FilterExtractor {
 
         for( Operator succ : children ) {
             filteredPlan.disconnect( op, succ );
-            removeFromFilteredPlan( succ );
+            // check if this successor has any other predecessor.
+            // if none, proceed with the removal.
+            List<Operator> predsOfsucc = filteredPlan.getPredecessors( succ );
+            if( predsOfsucc == null || predsOfsucc.size() == 0 ) {
+                removeFromFilteredPlan( succ );
+            }
         }
 
         filteredPlan.remove( op );

Modified: 
pig/branches/branch-0.17/test/org/apache/pig/test/TestNewPartitionFilterPushDown.java
URL: 
http://svn.apache.org/viewvc/pig/branches/branch-0.17/test/org/apache/pig/test/TestNewPartitionFilterPushDown.java?rev=1808927&r1=1808926&r2=1808927&view=diff
==============================================================================
--- 
pig/branches/branch-0.17/test/org/apache/pig/test/TestNewPartitionFilterPushDown.java
 (original)
+++ 
pig/branches/branch-0.17/test/org/apache/pig/test/TestNewPartitionFilterPushDown.java
 Tue Sep 19 18:29:09 2017
@@ -707,6 +707,13 @@ public class TestNewPartitionFilterPushD
                 "(not (browser#'type' is null))", true);
     }
 
+    @Test
+    public void testNegativeOrAndOr() throws Exception {
+        String q = query + "b = filter a by dstid != 10 OR ((dstid < 3000 and 
srcid == 1000) OR (dstid >= 3000 and srcid == 2000));" +
+                   "store b into 'out';";
+        test(q, Arrays.asList("srcid"), null, "((dstid != 10) or 
(((dstidLessThan3000) and (srcid == 1000)) or ((dstidGreaterThanEqual3000) and 
(srcid == 2000))))", true);
+    }
+
     //// helper methods ///////
     private PartitionFilterExtractor test(String query, List<String> 
partitionCols,
             String expPartFilterString, String expFilterString)


Reply via email to