Skip to content

Commit 0726b83

Browse files
committed
DRILL-7774: IS NOT NULL predicate fails with NPE for the case of non-existing columns with non-deterministic expression
1 parent dbd74c2 commit 0726b83

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

exec/java-exec/src/main/java/org/apache/drill/exec/expr/FilterBuilder.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,9 @@ private LogicalExpression handleIsFunction(FunctionHolderExpression functionHold
304304
}
305305
LogicalExpression arg = functionHolderExpression.args.get(0);
306306

307-
return IsPredicate.createIsPredicate(funcName, arg.accept(this, value));
307+
LogicalExpression expression = arg.accept(this, value);
308+
309+
return expression == null ? null : IsPredicate.createIsPredicate(funcName, expression);
308310
}
309311

310312
private static boolean isCompareFunction(String funcName) {

exec/java-exec/src/test/java/org/apache/drill/exec/store/parquet/TestParquetFilterPushDown.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -683,6 +683,19 @@ public void testMinTrueMaxTrue() {
683683
assertEquals(RowsMatch.ALL, isNotFalse.matches(re));
684684
}
685685

686+
@Test
687+
public void tesNonDeterministicIsNotNullWithNonExistingColumn() throws Exception {
688+
String query = "select count(*) as cnt from cp.`tpch/nation.parquet`\n" +
689+
"where (case when random() = 1 then true else null end * t) is not null";
690+
691+
testBuilder()
692+
.sqlQuery(query)
693+
.unOrdered()
694+
.baselineColumns("cnt")
695+
.baselineValues(0L)
696+
.go();
697+
}
698+
686699
@Test
687700
public void testParquetSingleRowGroupFilterRemoving() throws Exception {
688701
test("create table dfs.tmp.`singleRowGroupTable` as select * from cp.`tpch/nation.parquet`");

0 commit comments

Comments
 (0)