impala-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject [2/8] incubator-impala git commit: IMPALA-5812: Fix NPE when joining on empty const select
Date Thu, 07 Sep 2017 03:50:20 GMT
IMPALA-5812: Fix NPE when joining on empty const select

A NPE is thrown during the creation of the single node plan of a query
consisting of a cross join with a constant select that returns
an empty result set. This happens because when an empty-set plan node
is created, its tupleIds_ and tblRefIds_ are initialized with the
tuple ID of a newly create tuple that does not map to any existing
tableRefs. This causes a null pre-check to fail during the creation
of the join node when it tries to fetch the tableRef from that new
tuple Id in the empty-set node but doesn't find one.

Added a planner test.

Change-Id: I6e425dbcb442aeeac687e103774823d3f50e6436
Reviewed-by: Alex Behm <>
Tested-by: Impala Public Jenkins


Branch: refs/heads/master
Commit: 4c9b46a904c5b660ab5faa33cf1c58ab6417d799
Parents: 91f7bc1
Author: Bikramjeet Vig <>
Authored: Tue Sep 5 15:56:36 2017 -0700
Committer: Impala Public Jenkins <>
Committed: Wed Sep 6 22:49:05 2017 +0000

 .../apache/impala/planner/   |  2 ++
 .../queries/PlannerTest/empty.test                 | 17 +++++++++++++++++
 2 files changed, 19 insertions(+)
diff --git a/fe/src/main/java/org/apache/impala/planner/ b/fe/src/main/java/org/apache/impala/planner/
index 8d82409..d72e818 100644
--- a/fe/src/main/java/org/apache/impala/planner/
+++ b/fe/src/main/java/org/apache/impala/planner/
@@ -1057,6 +1057,8 @@ public class SingleNodePlanner {
           // true for an outer-joined inline view that has no table refs.
+          // The tblRef materialized by this node is still the 'inlineViewRef'.
+          emptySetNode.setTblRefIds(Lists.newArrayList(inlineViewRef.getId()));
           return emptySetNode;
         // Analysis should have generated a tuple id into which to materialize the exprs.
diff --git a/testdata/workloads/functional-planner/queries/PlannerTest/empty.test b/testdata/workloads/functional-planner/queries/PlannerTest/empty.test
index 7ea44e0..c85d8ec 100644
--- a/testdata/workloads/functional-planner/queries/PlannerTest/empty.test
+++ b/testdata/workloads/functional-planner/queries/PlannerTest/empty.test
@@ -550,3 +550,20 @@ PLAN-ROOT SINK
+---- QUERY
+# IMPALA-5812: Test that a cross join with a constant select that returns an empty result
+# set translates into an EMPTYSET in the final plan
+select count(*) from functional.alltypes x cross join (select 1 as j) y where j is null
+---- PLAN
+|  output: count(*)
+00:SCAN HDFS [functional.alltypes x]
+   partitions=24/24 files=24 size=478.45KB

View raw message