Repository: incubator-impala Updated Branches: refs/heads/master fda539a1d -> 227a180ab
IMPALA-5438: Always eval union const exprs in subplan. The bug was that the constant exprs of a union were only evaluated for the first fragment instance. However, for a union inside a subplan, we should always evaluate the constant exprs. Testing: - Added a regression test. - Locally ran test_nested_types.py and the union tests in test_queries.py Change-Id: Icd2f21f0213188e2304f8e9536019c7940c07768 Reviewed-on: http://gerrit.cloudera.org:8080/7091 Reviewed-by: Alex Behm <[email protected]> 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/edf9f2ff Tree: http://git-wip-us.apache.org/repos/asf/incubator-impala/tree/edf9f2ff Diff: http://git-wip-us.apache.org/repos/asf/incubator-impala/diff/edf9f2ff Branch: refs/heads/master Commit: edf9f2ffb6cdfed3884415e468cdf0b08b63aadd Parents: fda539a Author: Alex Behm <[email protected]> Authored: Mon Jun 5 16:41:53 2017 -0700 Committer: Impala Public Jenkins <[email protected]> Committed: Tue Jun 6 18:02:49 2017 +0000 ---------------------------------------------------------------------- be/src/exec/union-node.cc | 2 +- be/src/exec/union-node.h | 2 +- .../queries/QueryTest/nested-types-subplan.test | 17 ++++++++++++++++- 3 files changed, 18 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/edf9f2ff/be/src/exec/union-node.cc ---------------------------------------------------------------------- diff --git a/be/src/exec/union-node.cc b/be/src/exec/union-node.cc index cd16bea..e1912c9 100644 --- a/be/src/exec/union-node.cc +++ b/be/src/exec/union-node.cc @@ -246,7 +246,7 @@ Status UnionNode::GetNextMaterialized(RuntimeState* state, RowBatch* row_batch) } Status UnionNode::GetNextConst(RuntimeState* state, RowBatch* row_batch) { - DCHECK_EQ(state->instance_ctx().per_fragment_instance_idx, 0); + DCHECK(state->instance_ctx().per_fragment_instance_idx == 0 || IsInSubplan()); DCHECK_LT(const_expr_list_idx_, const_expr_lists_.size()); // Create new tuple buffer for row_batch. int64_t tuple_buf_size; http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/edf9f2ff/be/src/exec/union-node.h ---------------------------------------------------------------------- diff --git a/be/src/exec/union-node.h b/be/src/exec/union-node.h index 311ae17..79fdfba 100644 --- a/be/src/exec/union-node.h +++ b/be/src/exec/union-node.h @@ -149,7 +149,7 @@ class UnionNode : public ExecNode { /// Returns true if there are still rows to be returned from constant expressions. bool HasMoreConst(const RuntimeState* state) const { - return state->instance_ctx().per_fragment_instance_idx == 0 && + return (state->instance_ctx().per_fragment_instance_idx == 0 || IsInSubplan()) && const_expr_list_idx_ < const_expr_lists_.size(); } http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/edf9f2ff/testdata/workloads/functional-query/queries/QueryTest/nested-types-subplan.test ---------------------------------------------------------------------- diff --git a/testdata/workloads/functional-query/queries/QueryTest/nested-types-subplan.test b/testdata/workloads/functional-query/queries/QueryTest/nested-types-subplan.test index 9590c1b..45116e6 100644 --- a/testdata/workloads/functional-query/queries/QueryTest/nested-types-subplan.test +++ b/testdata/workloads/functional-query/queries/QueryTest/nested-types-subplan.test @@ -577,7 +577,7 @@ where c_custkey = 1 BIGINT,BIGINT ==== ---- QUERY -# IMPALA-3678: union in a subplan - passthrough should be disabled. +# IMPALA-3678: Union in a subplan - passthrough should be disabled. select count(c.c_custkey), count(v.tot_price) from tpch_nested_parquet.customer c, ( select sum(o_totalprice) tot_price from c.c_orders @@ -611,3 +611,18 @@ WHERE ca.o_orderkey < cb.o_orderkey limit 2) v limit 51 ---- TYPES BIGINT ==== +---- QUERY +# IMPALA-5438: Union with constant exprs in a subplan. The 'c_custkey % 100' was chosen +# to have all impalads produce results to make sure the constant exprs in the union are +# evaluated regardless of which fragment instance they are in. +select c_custkey, order_cnt, union_cnt from tpch_nested_parquet.customer c, + (select count(o_orderkey) order_cnt from c.c_orders) v, + (select count(o_orderkey) union_cnt from ( + select o_orderkey from c.c_orders + union all + values(11),(22),(33)) v) v2 +where c_custkey % 100 = 0 and order_cnt != union_cnt - 3; +---- RESULTS +---- TYPES +bigint,bigint,bigint +====
