This is an automated email from the ASF dual-hosted git repository.

volodymyr pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/drill.git


The following commit(s) were added to refs/heads/master by this push:
     new 0726b83  DRILL-7774: IS NOT NULL predicate fails with NPE for the case 
of non-existing columns with non-deterministic expression
0726b83 is described below

commit 0726b83d9347cbb8bd1bc64a8d10c12c1125549a
Author: Volodymyr Vysotskyi <[email protected]>
AuthorDate: Thu Aug 6 22:55:23 2020 +0300

    DRILL-7774: IS NOT NULL predicate fails with NPE for the case of 
non-existing columns with non-deterministic expression
---
 .../main/java/org/apache/drill/exec/expr/FilterBuilder.java |  4 +++-
 .../drill/exec/store/parquet/TestParquetFilterPushDown.java | 13 +++++++++++++
 2 files changed, 16 insertions(+), 1 deletion(-)

diff --git 
a/exec/java-exec/src/main/java/org/apache/drill/exec/expr/FilterBuilder.java 
b/exec/java-exec/src/main/java/org/apache/drill/exec/expr/FilterBuilder.java
index f4c19cb..a2afe12 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/expr/FilterBuilder.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/expr/FilterBuilder.java
@@ -304,7 +304,9 @@ public class FilterBuilder extends 
AbstractExprVisitor<LogicalExpression, Set<Lo
     }
     LogicalExpression arg = functionHolderExpression.args.get(0);
 
-    return IsPredicate.createIsPredicate(funcName, arg.accept(this, value));
+    LogicalExpression expression = arg.accept(this, value);
+
+    return expression == null ? null : IsPredicate.createIsPredicate(funcName, 
expression);
   }
 
   private static boolean isCompareFunction(String funcName) {
diff --git 
a/exec/java-exec/src/test/java/org/apache/drill/exec/store/parquet/TestParquetFilterPushDown.java
 
b/exec/java-exec/src/test/java/org/apache/drill/exec/store/parquet/TestParquetFilterPushDown.java
index 25ba8fd..f530945 100644
--- 
a/exec/java-exec/src/test/java/org/apache/drill/exec/store/parquet/TestParquetFilterPushDown.java
+++ 
b/exec/java-exec/src/test/java/org/apache/drill/exec/store/parquet/TestParquetFilterPushDown.java
@@ -684,6 +684,19 @@ public class TestParquetFilterPushDown extends 
PlanTestBase {
   }
 
   @Test
+  public void tesNonDeterministicIsNotNullWithNonExistingColumn() throws 
Exception {
+    String query = "select count(*) as cnt from cp.`tpch/nation.parquet`\n" +
+        "where (case when random() = 1 then true else null end * t) is not 
null";
+
+    testBuilder()
+        .sqlQuery(query)
+        .unOrdered()
+        .baselineColumns("cnt")
+        .baselineValues(0L)
+        .go();
+  }
+
+  @Test
   public void testParquetSingleRowGroupFilterRemoving() throws Exception {
     test("create table dfs.tmp.`singleRowGroupTable` as select * from 
cp.`tpch/nation.parquet`");
 

Reply via email to