IMPALA-5363: Reset probe_batch_ after reaching limit For every new iteration of a subplan there are leftover rows from the previous iteration of a subplan. This change transfers the ownership from the probe_batch_ to output_batch_ and resets the probe_batch_ on hitting the limit.
Change-Id: Iafd621d33a4e2fac42391504566ffd8dd0e18a67 Reviewed-on: http://gerrit.cloudera.org:8080/7014 Tested-by: Impala Public Jenkins Reviewed-by: Lars Volker <[email protected]> Project: http://git-wip-us.apache.org/repos/asf/incubator-impala/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-impala/commit/9c8c5908 Tree: http://git-wip-us.apache.org/repos/asf/incubator-impala/tree/9c8c5908 Diff: http://git-wip-us.apache.org/repos/asf/incubator-impala/diff/9c8c5908 Branch: refs/heads/master Commit: 9c8c5908867b61ff963cc14b182365f23d1f7b86 Parents: 98ae318 Author: aphadke <[email protected]> Authored: Sat May 27 08:20:57 2017 -0700 Committer: Lars Volker <[email protected]> Committed: Tue Jun 6 00:53:13 2017 +0000 ---------------------------------------------------------------------- be/src/exec/partitioned-hash-join-node.cc | 15 ++++++------- .../queries/QueryTest/nested-types-subplan.test | 22 ++++++++++++++++++++ 2 files changed, 28 insertions(+), 9 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/9c8c5908/be/src/exec/partitioned-hash-join-node.cc ---------------------------------------------------------------------- diff --git a/be/src/exec/partitioned-hash-join-node.cc b/be/src/exec/partitioned-hash-join-node.cc index 0c91b47..d3a10d3 100644 --- a/be/src/exec/partitioned-hash-join-node.cc +++ b/be/src/exec/partitioned-hash-join-node.cc @@ -493,15 +493,9 @@ Status PartitionedHashJoinNode::GetNext(RuntimeState* state, RowBatch* out_batch RETURN_IF_ERROR(ExecDebugAction(TExecNodePhase::GETNEXT, state)); DCHECK(!out_batch->AtCapacity()); - if (ReachedLimit()) { - *eos = true; - return Status::OK(); - } else { - *eos = false; - } - Status status = Status::OK(); - while (true) { + *eos = false; + while (!ReachedLimit()) { DCHECK(!*eos); DCHECK(status.ok()); DCHECK_NE(state_, PARTITIONING_BUILD) << "Should not be in GetNext()"; @@ -638,7 +632,10 @@ Status PartitionedHashJoinNode::GetNext(RuntimeState* state, RowBatch* out_batch break; } - if (ReachedLimit()) *eos = true; + if (ReachedLimit()) { + probe_batch_->TransferResourceOwnership(out_batch); + *eos = true; + } return Status::OK(); } http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/9c8c5908/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 90c925d..9590c1b 100644 --- a/testdata/workloads/functional-query/queries/QueryTest/nested-types-subplan.test +++ b/testdata/workloads/functional-query/queries/QueryTest/nested-types-subplan.test @@ -589,3 +589,25 @@ from tpch_nested_parquet.customer c, ( ---- TYPES bigint,bigint ==== +---- QUERY +# IMPALA-5363: Reset probe_batch_ after reaching limit. +# Query with a partitioned hash join inside a subplan +select count(*) FROM tpch_nested_parquet.customer c, (SELECT ca.o_orderkey okey, +ca.o_orderpriority opriority FROM c.c_orders ca, c.c_orders cb +WHERE ca.o_orderkey = cb.o_orderkey limit 2) v limit 51 +---- RESULTS +1500000 +---- TYPES +BIGINT +==== +---- QUERY +# IMPALA-5363: Reset probe_batch_ after reaching limit. +# Query with a Nested loop join inside a subplan +select count(*) FROM tpch_nested_parquet.customer c, (SELECT ca.o_orderkey okey, +ca.o_orderpriority opriority FROM c.c_orders ca, c.c_orders cb +WHERE ca.o_orderkey < cb.o_orderkey limit 2) v limit 51 +---- RESULTS +199835 +---- TYPES +BIGINT +====
