This is an automated email from the ASF dual-hosted git repository.
gabriellee pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push:
new d27201f331 [fix](nested_loop_join)got incorrect result from nested
loop join without condition (#18139)
d27201f331 is described below
commit d27201f3319cbcfb5d11093de4f7b04f1d071516
Author: Jerry Hu <[email protected]>
AuthorDate: Tue Mar 28 16:20:05 2023 +0800
[fix](nested_loop_join)got incorrect result from nested loop join without
condition (#18139)
---
be/src/vec/exec/join/vnested_loop_join_node.cpp | 20 ++++++
.../correctness_p0/test_join_without_condition.out | 12 ++++
.../test_join_without_condition.groovy | 73 ++++++++++++++++++++++
3 files changed, 105 insertions(+)
diff --git a/be/src/vec/exec/join/vnested_loop_join_node.cpp
b/be/src/vec/exec/join/vnested_loop_join_node.cpp
index 3a26ef165c..c995929ca1 100644
--- a/be/src/vec/exec/join/vnested_loop_join_node.cpp
+++ b/be/src/vec/exec/join/vnested_loop_join_node.cpp
@@ -592,6 +592,26 @@ Status
VNestedLoopJoinNode::_do_filtering_and_update_visited_flags(Block* block,
block, column_to_keep, build_block_idx,
processed_blocks_num, materialize,
filter);
}
+ } else if (block->rows() > 0) {
+ if constexpr (SetBuildSideFlag) {
+ for (size_t i = 0; i < processed_blocks_num; i++) {
+ auto& build_side_flag =
+
assert_cast<ColumnUInt8*>(_build_side_visited_flags[build_block_idx].get())
+ ->get_data();
+ auto* __restrict build_side_flag_data = build_side_flag.data();
+ auto cur_sz = build_side_flag.size();
+ _offset_stack.pop();
+ memset(reinterpret_cast<void*>(build_side_flag_data), 1,
cur_sz);
+ build_block_idx =
+ build_block_idx == 0 ? _build_blocks.size() - 1 :
build_block_idx - 1;
+ }
+ }
+ if constexpr (SetProbeSideFlag) {
+ _cur_probe_row_visited_flags = true;
+ }
+ if (!materialize) {
+ CLEAR_BLOCK
+ }
}
Block::erase_useless_column(block, column_to_keep);
return Status::OK();
diff --git
a/regression-test/data/correctness_p0/test_join_without_condition.out
b/regression-test/data/correctness_p0/test_join_without_condition.out
new file mode 100644
index 0000000000..6a9fdf3abf
--- /dev/null
+++ b/regression-test/data/correctness_p0/test_join_without_condition.out
@@ -0,0 +1,12 @@
+-- This file is automatically generated. You should know what you did if you
want to edit this
+-- !select --
+1 4
+1 5
+1 6
+2 4
+2 5
+2 6
+3 4
+3 5
+3 6
+
diff --git
a/regression-test/suites/correctness_p0/test_join_without_condition.groovy
b/regression-test/suites/correctness_p0/test_join_without_condition.groovy
new file mode 100644
index 0000000000..c56144757a
--- /dev/null
+++ b/regression-test/suites/correctness_p0/test_join_without_condition.groovy
@@ -0,0 +1,73 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+suite("test_join_without_condition") {
+ sql """
+ drop table if exists test_join_without_condition_a;
+ """
+
+ sql """
+ drop table if exists test_join_without_condition_b;
+ """
+
+ sql """
+ create table if not exists test_join_without_condition_a ( a int not
null )
+ ENGINE=OLAP
+ DISTRIBUTED BY HASH(a) BUCKETS 1
+ PROPERTIES (
+ "replication_allocation" = "tag.location.default: 1",
+ "in_memory" = "false",
+ "storage_format" = "V2"
+ );
+ """
+
+ sql """
+ create table if not exists test_join_without_condition_b ( a int not
null )
+ ENGINE=OLAP
+ DISTRIBUTED BY HASH(a) BUCKETS 1
+ PROPERTIES (
+ "replication_allocation" = "tag.location.default: 1",
+ "in_memory" = "false",
+ "storage_format" = "V2"
+ );
+ """
+
+ sql """
+ insert into test_join_without_condition_a values(1), (2), (3);
+ """
+
+ sql """
+ insert into test_join_without_condition_b values(4), (5), (6);
+ """
+
+ // here condition 'b.a > 1' will be pushed down to scan node.
+ qt_select """
+ select a.a, b.a
+ from
+ test_join_without_condition_a a
+ left join test_join_without_condition_b b on b.a > 1
+ order by a.a, b.a;
+ """
+
+ sql """
+ drop table if exists test_join_without_condition_a;
+ """
+
+ sql """
+ drop table if exists test_join_without_condition_b;
+ """
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]