Skip to content

Commit ad2d203

Browse files
authored
[fix](pipeline) fix use error row desc when origin block clear apache#32803 (apache#32849)
* fix * add case
1 parent bda35f9 commit ad2d203

7 files changed

Lines changed: 113 additions & 11 deletions

File tree

‎be/src/exec/exec_node.h‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ class ExecNode {
127127
bool has_output_row_descriptor() const { return _output_row_descriptor != nullptr; }
128128
// If use projection, we should clear `_origin_block`.
129129
void clear_origin_block() {
130-
_origin_block.clear_column_data(_row_descriptor.num_materialized_slots());
130+
_origin_block.clear_column_data(intermediate_row_desc().num_materialized_slots());
131131
}
132132

133133
// Emit data, both need impl with method: sink
@@ -326,8 +326,8 @@ class ExecNode {
326326
std::shared_ptr<QueryStatistics> _query_statistics = nullptr;
327327

328328
//_keep_origin is used to avoid copying during projection,
329-
// currently set to true only in the nestloop join.
330-
bool _keep_origin = false;
329+
// currently set to false only in the nestloop join.
330+
bool _keep_origin = true;
331331

332332
private:
333333
static Status create_tree_helper(RuntimeState* state, ObjectPool* pool,

‎be/src/pipeline/exec/join_probe_operator.cpp‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,7 @@ Status JoinProbeLocalState<SharedStateArg, Derived>::_build_output_block(
8787
// and you could see a 'todo' in the Thrift definition.
8888
// Here, we have refactored it, but considering upgrade compatibility, we still need to retain the old code.
8989
if (!output_block->mem_reuse()) {
90-
vectorized::MutableBlock tmp(
91-
vectorized::VectorizedUtils::create_columns_with_type_and_name(p.row_desc()));
92-
output_block->swap(tmp.to_block());
90+
output_block->swap(origin_block->clone_empty());
9391
}
9492
output_block->swap(*origin_block);
9593
return Status::OK();

‎be/src/pipeline/pipeline_x/operator.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ Status OperatorXBase::close(RuntimeState* state) {
167167
}
168168

169169
void PipelineXLocalStateBase::clear_origin_block() {
170-
_origin_block.clear_column_data(_parent->_row_descriptor.num_materialized_slots());
170+
_origin_block.clear_column_data(_parent->intermediate_row_desc().num_materialized_slots());
171171
}
172172

173173
Status OperatorXBase::do_projections(RuntimeState* state, vectorized::Block* origin_block,

‎be/src/pipeline/pipeline_x/operator.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -328,8 +328,8 @@ class OperatorXBase : public OperatorBase {
328328
int _parallel_tasks = 0;
329329

330330
//_keep_origin is used to avoid copying during projection,
331-
// currently set to true only in the nestloop join.
332-
bool _keep_origin = false;
331+
// currently set to false only in the nestloop join.
332+
bool _keep_origin = true;
333333
};
334334

335335
template <typename LocalStateType>

‎be/src/vec/exec/join/vjoin_node_base.cpp‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,8 +185,7 @@ Status VJoinNodeBase::_build_output_block(Block* origin_block, Block* output_blo
185185
// and you could see a 'todo' in the Thrift definition.
186186
// Here, we have refactored it, but considering upgrade compatibility, we still need to retain the old code.
187187
if (!output_block->mem_reuse()) {
188-
MutableBlock tmp(VectorizedUtils::create_columns_with_type_and_name(row_desc()));
189-
output_block->swap(tmp.to_block());
188+
output_block->swap(origin_block->clone_empty());
190189
}
191190
output_block->swap(*origin_block);
192191
return Status::OK();
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
-- This file is automatically generated. You should know what you did if you want to edit this
2+
-- !select_pipelineX --
3+
2020 -5.2
4+
5+
-- !select_pipeline --
6+
2020 -5.2
7+
8+
-- !select_non_pipeline --
9+
2020 -5.2
10+
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
// Licensed to the Apache Software Foundation (ASF) under one
2+
// or more contributor license agreements. See the NOTICE file
3+
// distributed with this work for additional information
4+
// regarding copyright ownership. The ASF licenses this file
5+
// to you under the Apache License, Version 2.0 (the
6+
// "License"); you may not use this file except in compliance
7+
// with the License. You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing,
12+
// software distributed under the License is distributed on an
13+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
// KIND, either express or implied. See the License for the
15+
// specific language governing permissions and limitations
16+
// under the License.
17+
18+
// The cases is copied from https://github.com/trinodb/trino/tree/master
19+
// /testing/trino-product-tests/src/main/resources/sql-tests/testcases/aggregate
20+
// and modified by Doris.
21+
22+
suite("test_probe_clean") {
23+
24+
sql """ drop table IF EXISTS clearblocktable1; """
25+
sql """
26+
CREATE TABLE IF NOT EXISTS clearblocktable1 (
27+
`col_int_undef_signed` INT NULL COMMENT "",
28+
`col_int_undef_signed_not_null` INT NOT NULL COMMENT "",
29+
`col_date_undef_signed_not_null` date(11) NOT NULL COMMENT "",
30+
31+
) ENGINE=OLAP
32+
DUPLICATE KEY(`col_int_undef_signed`)
33+
DISTRIBUTED BY HASH(`col_int_undef_signed`) BUCKETS 1
34+
PROPERTIES (
35+
'replication_num' = '1'
36+
);
37+
"""
38+
39+
40+
sql """
41+
insert into clearblocktable1 values(1,1,'2020-01-01');
42+
"""
43+
sql """
44+
drop table IF EXISTS clearblocktable2;
45+
"""
46+
sql """
47+
CREATE TABLE IF NOT EXISTS clearblocktable2 (
48+
`col_int_undef_signed` INT NULL COMMENT "",
49+
`col_int_undef_signed_not_null` INT NOT NULL COMMENT "",
50+
`col_date_undef_signed_not_null` date(11) NOT NULL COMMENT "",
51+
52+
) ENGINE=OLAP
53+
DUPLICATE KEY(`col_int_undef_signed`)
54+
DISTRIBUTED BY HASH(`col_int_undef_signed`) BUCKETS 1
55+
PROPERTIES (
56+
'replication_num' = '1'
57+
);
58+
"""
59+
60+
sql """
61+
insert into clearblocktable2 values(1,1,'2020-01-01');
62+
"""
63+
64+
sql """
65+
set enable_pipeline_x_engine=true, enable_pipeline_engine=true;
66+
"""
67+
qt_select_pipelineX """
68+
69+
SELECT YEAR(ifnull(clearblocktable1.`col_date_undef_signed_not_null`, clearblocktable1.`col_date_undef_signed_not_null`)) AS field1 ,
70+
CASE WHEN clearblocktable1.`col_int_undef_signed` != clearblocktable1.`col_int_undef_signed` * (8 + 1) THEN -5.2 ELSE clearblocktable1.`col_int_undef_signed` END AS field2
71+
FROM clearblocktable1 INNER JOIN clearblocktable2 ON clearblocktable2.`col_int_undef_signed` = clearblocktable1.`col_int_undef_signed` WHERE clearblocktable1.`col_int_undef_signed_not_null` <> 7;
72+
73+
"""
74+
75+
sql """
76+
set enable_pipeline_x_engine=false,enable_pipeline_engine=true;
77+
"""
78+
qt_select_pipeline """
79+
80+
SELECT YEAR(ifnull(clearblocktable1.`col_date_undef_signed_not_null`, clearblocktable1.`col_date_undef_signed_not_null`)) AS field1 ,
81+
CASE WHEN clearblocktable1.`col_int_undef_signed` != clearblocktable1.`col_int_undef_signed` * (8 + 1) THEN -5.2 ELSE clearblocktable1.`col_int_undef_signed` END AS field2
82+
FROM clearblocktable1 INNER JOIN clearblocktable2 ON clearblocktable2.`col_int_undef_signed` = clearblocktable1.`col_int_undef_signed` WHERE clearblocktable1.`col_int_undef_signed_not_null` <> 7;
83+
84+
"""
85+
86+
sql """
87+
set enable_pipeline_x_engine=false, enable_pipeline_engine=false;
88+
"""
89+
qt_select_non_pipeline """
90+
91+
SELECT YEAR(ifnull(clearblocktable1.`col_date_undef_signed_not_null`, clearblocktable1.`col_date_undef_signed_not_null`)) AS field1 ,
92+
CASE WHEN clearblocktable1.`col_int_undef_signed` != clearblocktable1.`col_int_undef_signed` * (8 + 1) THEN -5.2 ELSE clearblocktable1.`col_int_undef_signed` END AS field2
93+
FROM clearblocktable1 INNER JOIN clearblocktable2 ON clearblocktable2.`col_int_undef_signed` = clearblocktable1.`col_int_undef_signed` WHERE clearblocktable1.`col_int_undef_signed_not_null` <> 7;
94+
"""
95+
}

0 commit comments

Comments
 (0)