impala-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbap...@apache.org
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.

Testing:
Added a planner test.

Change-Id: I6e425dbcb442aeeac687e103774823d3f50e6436
Reviewed-on: http://gerrit.cloudera.org:8080/7971
Reviewed-by: Alex Behm <alex.behm@cloudera.com>
Tested-by: Impala Public Jenkins


Project: http://git-wip-us.apache.org/repos/asf/incubator-impala/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-impala/commit/4c9b46a9
Tree: http://git-wip-us.apache.org/repos/asf/incubator-impala/tree/4c9b46a9
Diff: http://git-wip-us.apache.org/repos/asf/incubator-impala/diff/4c9b46a9

Branch: refs/heads/master
Commit: 4c9b46a904c5b660ab5faa33cf1c58ab6417d799
Parents: 91f7bc1
Author: Bikramjeet Vig <bikramjeet.vig@cloudera.com>
Authored: Tue Sep 5 15:56:36 2017 -0700
Committer: Impala Public Jenkins <impala-public-jenkins@gerrit.cloudera.org>
Committed: Wed Sep 6 22:49:05 2017 +0000

----------------------------------------------------------------------
 .../apache/impala/planner/SingleNodePlanner.java   |  2 ++
 .../queries/PlannerTest/empty.test                 | 17 +++++++++++++++++
 2 files changed, 19 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/4c9b46a9/fe/src/main/java/org/apache/impala/planner/SingleNodePlanner.java
----------------------------------------------------------------------
diff --git a/fe/src/main/java/org/apache/impala/planner/SingleNodePlanner.java b/fe/src/main/java/org/apache/impala/planner/SingleNodePlanner.java
index 8d82409..d72e818 100644
--- a/fe/src/main/java/org/apache/impala/planner/SingleNodePlanner.java
+++ b/fe/src/main/java/org/apache/impala/planner/SingleNodePlanner.java
@@ -1057,6 +1057,8 @@ public class SingleNodePlanner {
           // true for an outer-joined inline view that has no table refs.
           Preconditions.checkState(!analyzer.isOuterJoined(inlineViewRef.getId()));
           emptySetNode.setOutputSmap(inlineViewRef.getSmap());
+          // 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.

http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/4c9b46a9/testdata/workloads/functional-planner/queries/PlannerTest/empty.test
----------------------------------------------------------------------
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
 |
 00:EMPTYSET
 ====
+---- 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
+PLAN-ROOT SINK
+|
+03:AGGREGATE [FINALIZE]
+|  output: count(*)
+|
+02:NESTED LOOP JOIN [CROSS JOIN]
+|
+|--01:EMPTYSET
+|
+00:SCAN HDFS [functional.alltypes x]
+   partitions=24/24 files=24 size=478.45KB
+====


Mime
View raw message