Repository: drill
Updated Branches:
  refs/heads/master a0be3ae0a -> 9b88d5914


DRILL-4071: Detect nested holistic expressions while traversing filter tree for 
partition pruning


Project: http://git-wip-us.apache.org/repos/asf/drill/repo
Commit: http://git-wip-us.apache.org/repos/asf/drill/commit/9b88d591
Tree: http://git-wip-us.apache.org/repos/asf/drill/tree/9b88d591
Diff: http://git-wip-us.apache.org/repos/asf/drill/diff/9b88d591

Branch: refs/heads/master
Commit: 9b88d591450110b4a238d228138097c0f664a73e
Parents: a0be3ae
Author: Mehant Baid <[email protected]>
Authored: Tue Nov 10 23:31:16 2015 -0800
Committer: Mehant Baid <[email protected]>
Committed: Wed Nov 11 22:15:12 2015 -0800

----------------------------------------------------------------------
 .../logical/partition/FindPartitionConditions.java    |  7 +++++++
 .../java/org/apache/drill/TestPartitionFilter.java    | 14 ++++++++++++++
 2 files changed, 21 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/drill/blob/9b88d591/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 5f14e3b..382d686 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
@@ -204,6 +204,13 @@ public class FindPartitionConditions extends 
RexVisitorImpl<Void> {
   }
 
   private boolean isHolisticExpression(RexCall call) {
+    /* If we are already processing a holistic expression then all
+     * nested expressions should be treated holistically as well
+     */
+    if (holisticExpression > 0) {
+      return true;
+    }
+
     if (call.getOperator().getSyntax() == SqlSyntax.SPECIAL ||
         call.getOperator().getSyntax() == SqlSyntax.FUNCTION) {
       return true;

http://git-wip-us.apache.org/repos/asf/drill/blob/9b88d591/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 d99a346..1057044 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
@@ -295,5 +295,19 @@ public class TestPartitionFilter extends PlanTestBase {
     testExcludeFilter(query, 1, "Filter", 1);
   }
 
+  // Coalesce filter is on the non directory column. DRILL-4071
+  @Test
+  public void testPartitionWithCoalesceFilter_1() throws Exception {
+    String query = String.format("select 1 from 
dfs_test.`%s/multilevel/parquet` where dir0=1994 and dir1='Q1' and 
coalesce(o_custkey, 0) = 890", TEST_RES_PATH);
+    testIncludeFilter(query, 1, "Filter", 1);
+  }
+
+  // Coalesce filter is on the directory column
+  @Test
+  public void testPartitionWithCoalesceFilter_2() throws Exception {
+    String query = String.format("select 1 from 
dfs_test.`%s/multilevel/parquet` where dir0=1994 and o_custkey = 890 and 
coalesce(dir1, 'NA') = 'Q1'", TEST_RES_PATH);
+    testIncludeFilter(query, 1, "Filter", 1);
+  }
+
 
 }
\ No newline at end of file

Reply via email to