DRILL-1610: Don't apply partition pruning optimization if one of the disjuncts don't meet pruning criteria
Project: http://git-wip-us.apache.org/repos/asf/incubator-drill/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-drill/commit/5ad6774e Tree: http://git-wip-us.apache.org/repos/asf/incubator-drill/tree/5ad6774e Diff: http://git-wip-us.apache.org/repos/asf/incubator-drill/diff/5ad6774e Branch: refs/heads/master Commit: 5ad6774e96b5d79a7864376c5f45bc0ed753b395 Parents: 3c3b3d5 Author: Mehant Baid <[email protected]> Authored: Wed Nov 12 18:25:53 2014 -0800 Committer: Jacques Nadeau <[email protected]> Committed: Thu Nov 13 09:17:27 2014 -0800 ---------------------------------------------------------------------- .../java/org/apache/drill/exec/TestHivePartitionPruning.java | 5 ++++- .../org/apache/drill/exec/planner/logical/DirPathBuilder.java | 6 ++++++ 2 files changed, 10 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/5ad6774e/contrib/storage-hive/core/src/test/java/org/apache/drill/exec/TestHivePartitionPruning.java ---------------------------------------------------------------------- diff --git a/contrib/storage-hive/core/src/test/java/org/apache/drill/exec/TestHivePartitionPruning.java b/contrib/storage-hive/core/src/test/java/org/apache/drill/exec/TestHivePartitionPruning.java index 8d42fca..b75f7d0 100644 --- a/contrib/storage-hive/core/src/test/java/org/apache/drill/exec/TestHivePartitionPruning.java +++ b/contrib/storage-hive/core/src/test/java/org/apache/drill/exec/TestHivePartitionPruning.java @@ -40,7 +40,10 @@ public class TestHivePartitionPruning extends PlanTestBase { assert plan.contains("Filter") == false; } - @Test + /* Partition pruning is not supported for disjuncts that do not meet pruning criteria. + * Will be enabled when we can do wild card comparison for partition pruning + */ + @Ignore public void testDisjunctsPartitionFilter() throws Exception { String query = "explain plan for select * from hive.`default`.partition_pruning_test where (c = 1) or (d = 1)"; String plan = getPlanInString(query, OPTIQ_FORMAT); http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/5ad6774e/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DirPathBuilder.java ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DirPathBuilder.java b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DirPathBuilder.java index 7972d74..da883e4 100644 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DirPathBuilder.java +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DirPathBuilder.java @@ -17,6 +17,7 @@ */ package org.apache.drill.exec.planner.logical; +import java.util.ArrayList; import java.util.List; import org.apache.drill.common.expression.FieldReference; @@ -55,6 +56,7 @@ public class DirPathBuilder extends RexVisitorImpl <SchemaPath> { private List<String> dirNameList; private List<RexNode> conjunctList; private List<String> dirPathList = Lists.newArrayList(); + private final static List<String> emptyDirPathList = new ArrayList<>(0); private RexNode currentConjunct = null; // the current conjunct are we evaluating during visitor traversal private RexNode finalCondition = null; // placeholder for the final filter condition private boolean dirMatch = false; @@ -133,7 +135,11 @@ public class DirPathBuilder extends RexVisitorImpl <SchemaPath> { } if (!dirPath.equals(EMPTY_STRING)) { dirPathList.add(dirPath); + } else { + // If one of the disjuncts do not satisfy our criteria then we shouldn't apply any optimization + return emptyDirPathList; } + if (buildConjunction) { RexNode newConjunct = RexUtil.composeConjunction(builder, conjuncts, false); newDisjunctList.add(newConjunct);
