diff --git a/fe/src/main/java/com/cloudera/impala/planner/EmptySetNode.java b/fe/src/main/java/com/cloudera/impala/planner/EmptySetNode.java index aabae161c..a8c527ea9 100644 --- a/fe/src/main/java/com/cloudera/impala/planner/EmptySetNode.java +++ b/fe/src/main/java/com/cloudera/impala/planner/EmptySetNode.java @@ -42,6 +42,11 @@ public class EmptySetNode extends PlanNode { @Override public void init(Analyzer analyzer) throws InternalException { + // If the physical output tuple produced by an AnalyticEvalNode wasn't created + // the logical output tuple is returned by getMaterializedTupleIds(). It needs + // to be set as materialized (even though it isn't) to avoid failing precondition + // checks generating the thrift for slot refs that may reference this tuple. + for (TupleId id: tupleIds_) analyzer.getTupleDesc(id).setIsMaterialized(true); computeMemLayout(analyzer); computeStats(analyzer); } diff --git a/fe/src/main/java/com/cloudera/impala/planner/Planner.java b/fe/src/main/java/com/cloudera/impala/planner/Planner.java index 87e2a966d..7999aae27 100644 --- a/fe/src/main/java/com/cloudera/impala/planner/Planner.java +++ b/fe/src/main/java/com/cloudera/impala/planner/Planner.java @@ -1102,13 +1102,6 @@ public class Planner { throws InternalException { ArrayList tupleIds = Lists.newArrayList(); stmt.getMaterializedTupleIds(tupleIds); - - // If the physical output tuple produced by an AnalyticEvalNode wasn't created - // the logical output tuple is returned by getMaterializedTupleIds(). It needs - // to be set as materialized (even though it isn't) to avoid failing precondition - // checks generating the thrift for slot refs that may reference this tuple. - for (TupleId id: tupleIds) analyzer.getTupleDesc(id).setIsMaterialized(true); - EmptySetNode node = new EmptySetNode(nodeIdGenerator_.getNextId(), tupleIds); node.init(analyzer); return node; diff --git a/testdata/workloads/functional-query/queries/QueryTest/empty.test b/testdata/workloads/functional-query/queries/QueryTest/empty.test index d3966f269..014dd67d7 100644 --- a/testdata/workloads/functional-query/queries/QueryTest/empty.test +++ b/testdata/workloads/functional-query/queries/QueryTest/empty.test @@ -98,3 +98,22 @@ select MIN(int_col) OVER () FROM alltypes limit 0 ---- TYPES INT ==== +---- QUERY +# IMPALA-1524: Materialize all tuples produced by an EmptySet node. +SELECT +COALESCE(580, MAX(t2.year), 150) AS int_col FROM ( + SELECT + t1.bool_col, + COALESCE(LAG(-826, 69) OVER ( + ORDER BY t1.bool_col DESC, COALESCE(t2.int_col, t2.smallint_col, t2.id)), 279, -764) AS int_col, + COALESCE(t2.int_col, t2.smallint_col, t2.id) AS int_col_2 + FROM functional.alltypestiny t1 + INNER JOIN functional.alltypestiny t2 + ON ((t2.bigint_col) = (t1.id)) AND ((t2.timestamp_col) = (t1.timestamp_col))) t1 +INNER JOIN functional.alltypes t2 ON (t2.year) = (t1.int_col_2) +WHERE (-339.22) IN (-922.68, -254.84) +---- RESULTS +580 +---- TYPES +INT +====