Skip to content

Commit 2e12617

Browse files
committed
[fix](join)the build and probe expr should be calculated before converting input block to nullable
1 parent 1f7829e commit 2e12617

File tree

4 files changed

+99
-8
lines changed

4 files changed

+99
-8
lines changed

be/src/vec/columns/column_const.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ class ColumnConst final : public COWHelper<IColumn, ColumnConst> {
185185
return false;
186186
}
187187

188-
// bool is_nullable() const override { return is_column_nullable(*data); }
188+
bool is_nullable() const override { return data->is_nullable(); }
189189
bool only_null() const override { return data->is_null_at(0); }
190190
bool is_numeric() const override { return data->is_numeric(); }
191191
bool is_fixed_and_contiguous() const override { return data->is_fixed_and_contiguous(); }

be/src/vec/exec/join/vhash_join_node.cpp

+6-7
Original file line numberDiff line numberDiff line change
@@ -997,10 +997,6 @@ Status HashJoinNode::get_next(RuntimeState* state, Block* output_block, bool* eo
997997
probe_rows = _probe_block.rows();
998998
if (probe_rows != 0) {
999999
COUNTER_UPDATE(_probe_rows_counter, probe_rows);
1000-
if (_join_op == TJoinOp::RIGHT_OUTER_JOIN || _join_op == TJoinOp::FULL_OUTER_JOIN) {
1001-
_probe_column_convert_to_null = _convert_block_to_null(_probe_block);
1002-
}
1003-
10041000
int probe_expr_ctxs_sz = _probe_expr_ctxs.size();
10051001
_probe_columns.resize(probe_expr_ctxs_sz);
10061002
if (_null_map_column == nullptr) {
@@ -1024,6 +1020,9 @@ Status HashJoinNode::get_next(RuntimeState* state, Block* output_block, bool* eo
10241020
_hash_table_variants);
10251021

10261022
RETURN_IF_ERROR(st);
1023+
if (_join_op == TJoinOp::RIGHT_OUTER_JOIN || _join_op == TJoinOp::FULL_OUTER_JOIN) {
1024+
_probe_column_convert_to_null = _convert_block_to_null(_probe_block);
1025+
}
10271026
}
10281027
}
10291028

@@ -1323,9 +1322,6 @@ Status HashJoinNode::_extract_probe_join_column(Block& block, NullMap& null_map,
13231322

13241323
Status HashJoinNode::_process_build_block(RuntimeState* state, Block& block, uint8_t offset) {
13251324
SCOPED_TIMER(_build_table_timer);
1326-
if (_join_op == TJoinOp::LEFT_OUTER_JOIN || _join_op == TJoinOp::FULL_OUTER_JOIN) {
1327-
_convert_block_to_null(block);
1328-
}
13291325
size_t rows = block.rows();
13301326
if (UNLIKELY(rows == 0)) {
13311327
return Status::OK();
@@ -1372,6 +1368,9 @@ Status HashJoinNode::_process_build_block(RuntimeState* state, Block& block, uin
13721368
},
13731369
_hash_table_variants);
13741370

1371+
if (_join_op == TJoinOp::LEFT_OUTER_JOIN || _join_op == TJoinOp::FULL_OUTER_JOIN) {
1372+
_convert_block_to_null(block);
1373+
}
13751374
return st;
13761375
}
13771376

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
-- This file is automatically generated. You should know what you did if you want to edit this
2+
-- !select --
3+
1
4+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
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+
suite("test_outer_join_with_subquery") {
19+
sql """
20+
drop table if exists test_outer_join_with_subquery_outerjoin_A;
21+
"""
22+
23+
sql """
24+
drop table if exists test_outer_join_with_subquery_outerjoin_B;
25+
"""
26+
27+
sql """
28+
create table test_outer_join_with_subquery_outerjoin_A ( a int not null )
29+
ENGINE=OLAP
30+
DISTRIBUTED BY HASH(a) BUCKETS 1
31+
PROPERTIES (
32+
"replication_allocation" = "tag.location.default: 1",
33+
"in_memory" = "false",
34+
"storage_format" = "V2"
35+
);
36+
"""
37+
38+
sql """
39+
create table test_outer_join_with_subquery_outerjoin_B ( a int not null )
40+
ENGINE=OLAP
41+
DISTRIBUTED BY HASH(a) BUCKETS 1
42+
PROPERTIES (
43+
"replication_allocation" = "tag.location.default: 1",
44+
"in_memory" = "false",
45+
"storage_format" = "V2"
46+
);
47+
"""
48+
49+
sql """
50+
insert into test_outer_join_with_subquery_outerjoin_A values( 1 );
51+
"""
52+
53+
sql """
54+
insert into test_outer_join_with_subquery_outerjoin_B values( 1 );
55+
"""
56+
57+
qt_select """
58+
select
59+
subq_1.c1
60+
from
61+
(
62+
select
63+
case
64+
when test_outer_join_with_subquery_outerjoin_A.a is NULL then test_outer_join_with_subquery_outerjoin_A.a
65+
else test_outer_join_with_subquery_outerjoin_A.a
66+
end as c1
67+
from
68+
test_outer_join_with_subquery_outerjoin_A
69+
) as subq_1
70+
full join (
71+
select
72+
case
73+
when test_outer_join_with_subquery_outerjoin_B.a is NULL then test_outer_join_with_subquery_outerjoin_B.a
74+
else test_outer_join_with_subquery_outerjoin_B.a
75+
end as c2
76+
from
77+
test_outer_join_with_subquery_outerjoin_B
78+
) as subq_2 on (subq_1.c1 = subq_2.c2);
79+
"""
80+
81+
sql """
82+
drop table if exists test_outer_join_with_subquery_outerjoin_A;
83+
"""
84+
85+
sql """
86+
drop table if exists test_outer_join_with_subquery_outerjoin_B;
87+
"""
88+
}

0 commit comments

Comments
 (0)