Repository: drill Updated Branches: refs/heads/master c040185dd -> 9878170d0
DRILL-4665: Fix partition pruning for filters containing LIKE (or other similar) predicate on non-partition column. close apache/drill#526 Project: http://git-wip-us.apache.org/repos/asf/drill/repo Commit: http://git-wip-us.apache.org/repos/asf/drill/commit/9878170d Tree: http://git-wip-us.apache.org/repos/asf/drill/tree/9878170d Diff: http://git-wip-us.apache.org/repos/asf/drill/diff/9878170d Branch: refs/heads/master Commit: 9878170d082a58af08b0b7b75494a76546d73580 Parents: c040185 Author: Gautam Parai <[email protected]> Authored: Thu Jun 16 19:36:07 2016 -0700 Committer: Aman Sinha <[email protected]> Committed: Thu Jul 14 16:28:51 2016 -0700 ---------------------------------------------------------------------- .../logical/partition/FindPartitionConditions.java | 4 ++-- .../java/org/apache/drill/TestPartitionFilter.java | 16 +++++++++++++++- 2 files changed, 17 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/drill/blob/9878170d/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/partition/FindPartitionConditions.java ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/partition/FindPartitionConditions.java b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/partition/FindPartitionConditions.java index 382d686..d1446b6 100644 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/partition/FindPartitionConditions.java +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/partition/FindPartitionConditions.java @@ -299,11 +299,11 @@ public class FindPartitionConditions extends RexVisitorImpl<Void> { if (callPushDirFilter == PushDirFilter.NO_PUSH) { - if (call.getKind() != SqlKind.AND) { + OpState currentOp = opStack.peek(); + if (currentOp.sqlOperator.getKind() != SqlKind.AND) { clearChildren(); } else { // AND op, check if we pushed some children - OpState currentOp = opStack.peek(); if (currentOp.children.size() > 0) { callPushDirFilter = PushDirFilter.PARTIAL_PUSH; } http://git-wip-us.apache.org/repos/asf/drill/blob/9878170d/exec/java-exec/src/test/java/org/apache/drill/TestPartitionFilter.java ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/test/java/org/apache/drill/TestPartitionFilter.java b/exec/java-exec/src/test/java/org/apache/drill/TestPartitionFilter.java index a2d101e..be2bfaf 100644 --- a/exec/java-exec/src/test/java/org/apache/drill/TestPartitionFilter.java +++ b/exec/java-exec/src/test/java/org/apache/drill/TestPartitionFilter.java @@ -362,4 +362,18 @@ public class TestPartitionFilter extends PlanTestBase { testIncludeFilter(query, 1, "Filter", 10); } -} \ No newline at end of file + @Test //DRILL-4665: Partition pruning should occur when LIKE predicate on non-partitioning column + public void testPartitionFilterWithLike() throws Exception { + // Also should be insensitive to the order of the predicates + String query1 = "select yr, qrtr from dfs_test.tmp.parquet where yr=1994 and o_custkey LIKE '%5%'"; + String query2 = "select yr, qrtr from dfs_test.tmp.parquet where o_custkey LIKE '%5%' and yr=1994"; + testIncludeFilter(query1, 4, "Filter", 9); + testIncludeFilter(query2, 4, "Filter", 9); + // Test when LIKE predicate on partitioning column + String query3 = "select yr, qrtr from dfs_test.tmp.parquet where yr LIKE '%1995%' and o_custkey LIKE '%3%'"; + String query4 = "select yr, qrtr from dfs_test.tmp.parquet where o_custkey LIKE '%3%' and yr LIKE '%1995%'"; + testIncludeFilter(query3, 4, "Filter", 16); + testIncludeFilter(query4, 4, "Filter", 16); + } + +}
