From c2faf4a8a13ba89f2f4f2bc4fbd878cffda53d1f Mon Sep 17 00:00:00 2001 From: Matthew Jacobs Date: Wed, 14 Dec 2016 15:58:59 -0800 Subject: [PATCH] IMPALA-4662: Fix NULL literal handling in Kudu IN list predicates The KuduScanNode attempts to push IN list predicates to the Kudu scan, but NULL literals cannot be pushed. The code in KuduScanNode needed to check if the Literals in the InPredicate is a NullLiteral, in which case the entire IN list should not be pushed to Kudu. The same handling is already in place for binary predicate pushdown. Change-Id: Iaf2c10a326373ad80aef51a85cec64071daefa7b Reviewed-on: http://gerrit.cloudera.org:8080/5505 Reviewed-by: Michael Brown Reviewed-by: Matthew Jacobs Tested-by: Internal Jenkins --- .../java/org/apache/impala/planner/KuduScanNode.java | 11 ++++++++--- .../functional-planner/queries/PlannerTest/kudu.test | 12 ++++++++++++ 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/fe/src/main/java/org/apache/impala/planner/KuduScanNode.java b/fe/src/main/java/org/apache/impala/planner/KuduScanNode.java index 580f5e0de..cdb620c9f 100644 --- a/fe/src/main/java/org/apache/impala/planner/KuduScanNode.java +++ b/fe/src/main/java/org/apache/impala/planner/KuduScanNode.java @@ -309,7 +309,7 @@ public class KuduScanNode extends ScanNode { SlotRef ref = (SlotRef) predicate.getChild(0); LiteralExpr literal = (LiteralExpr) predicate.getChild(1); - // Cannot push prediates with null literal values (KUDU-1595). + // Cannot push predicates with null literal values (KUDU-1595). if (literal instanceof NullLiteral) return false; String colName = ref.getDesc().getColumn().getName(); @@ -379,8 +379,13 @@ public class KuduScanNode extends ScanNode { List values = Lists.newArrayList(); for (int i = 1; i < predicate.getChildren().size(); ++i) { if (!(predicate.getChild(i).isLiteral())) return false; - Object value = getKuduInListValue((LiteralExpr) predicate.getChild(i)); - Preconditions.checkNotNull(value == null); + LiteralExpr literal = (LiteralExpr) predicate.getChild(i); + + // Cannot push predicates with null literal values (KUDU-1595). + if (literal instanceof NullLiteral) return false; + + Object value = getKuduInListValue(literal); + Preconditions.checkNotNull(value); values.add(value); } diff --git a/testdata/workloads/functional-planner/queries/PlannerTest/kudu.test b/testdata/workloads/functional-planner/queries/PlannerTest/kudu.test index 776882d9b..9f2270fbe 100644 --- a/testdata/workloads/functional-planner/queries/PlannerTest/kudu.test +++ b/testdata/workloads/functional-planner/queries/PlannerTest/kudu.test @@ -314,3 +314,15 @@ PLAN-ROOT SINK predicates: CAST(a.id AS STRING) > '123' kudu predicates: a.id > 10 ==== +# IMPALA-4662: Kudu analysis failure for NULL literal in IN list +# NULL literal in values list results in applying predicate at scan node +select id from functional_kudu.alltypestiny where +id in (1, null) and string_col in (null) and bool_col in (null) and double_col in (null) +and float_col in (null) and tinyint_col in (null) and smallint_col in (null) and +bigint_col in (null) +---- PLAN +PLAN-ROOT SINK +| +00:SCAN KUDU [functional_kudu.alltypestiny] + predicates: id IN (1, NULL), bigint_col IN (NULL), bool_col IN (NULL), double_col IN (NULL), float_col IN (NULL), smallint_col IN (NULL), string_col IN (NULL), tinyint_col IN (NULL) +====