This is an automated email from the ASF dual-hosted git repository. yiguolei pushed a commit to branch branch-2.1 in repository https://gitbox.apache.org/repos/asf/doris.git
commit 1456785aa14d64c236f00b9641a121561ec2088c Author: Jerry Hu <mrh...@gmail.com> AuthorDate: Fri Feb 23 10:57:25 2024 +0800 [fix](join) incorrect result of mark join in nested loop join (#31280) --- be/src/pipeline/exec/nested_loop_join_probe_operator.cpp | 10 +++------- be/src/vec/exec/join/vnested_loop_join_node.h | 9 ++------- .../data/nereids_p0/join/test_nestedloop_semi_anti_join.out | 9 +++++++++ .../data/query_p0/join/test_nestedloop_semi_anti_join.out | 9 +++++++++ .../nereids_p0/join/test_nestedloop_semi_anti_join.groovy | 8 ++++++++ .../suites/query_p0/join/test_nestedloop_semi_anti_join.groovy | 9 +++++++++ 6 files changed, 40 insertions(+), 14 deletions(-) diff --git a/be/src/pipeline/exec/nested_loop_join_probe_operator.cpp b/be/src/pipeline/exec/nested_loop_join_probe_operator.cpp index 8287219dfb2..04cdbded050 100644 --- a/be/src/pipeline/exec/nested_loop_join_probe_operator.cpp +++ b/be/src/pipeline/exec/nested_loop_join_probe_operator.cpp @@ -185,13 +185,9 @@ Status NestedLoopJoinProbeLocalState::generate_join_block_data(RuntimeState* sta _finalize_current_phase<false, JoinOpType::value == TJoinOp::LEFT_SEMI_JOIN>( _join_block, state->batch_size()); } - } - - if (_left_side_process_count) { - if (p._is_mark_join && _shared_state->build_blocks.empty()) { - DCHECK_EQ(JoinOpType::value, TJoinOp::CROSS_JOIN); - _append_left_data_with_null(_join_block); - } + } else if (_left_side_process_count && p._is_mark_join && + _shared_state->build_blocks.empty()) { + _append_left_data_with_null(_join_block); } } diff --git a/be/src/vec/exec/join/vnested_loop_join_node.h b/be/src/vec/exec/join/vnested_loop_join_node.h index a8021bb4251..fd31b651bd3 100644 --- a/be/src/vec/exec/join/vnested_loop_join_node.h +++ b/be/src/vec/exec/join/vnested_loop_join_node.h @@ -169,13 +169,8 @@ private: _finalize_current_phase<false, JoinOpType::value == TJoinOp::LEFT_SEMI_JOIN>( _join_block, state->batch_size()); } - } - - if (_left_side_process_count) { - if (_is_mark_join && _build_blocks.empty()) { - DCHECK_EQ(JoinOpType::value, TJoinOp::CROSS_JOIN); - _append_left_data_with_null(_join_block); - } + } else if (_left_side_process_count && _is_mark_join && _build_blocks.empty()) { + _append_left_data_with_null(_join_block); } } diff --git a/regression-test/data/nereids_p0/join/test_nestedloop_semi_anti_join.out b/regression-test/data/nereids_p0/join/test_nestedloop_semi_anti_join.out index 73d9152253a..a29e19b6032 100644 --- a/regression-test/data/nereids_p0/join/test_nestedloop_semi_anti_join.out +++ b/regression-test/data/nereids_p0/join/test_nestedloop_semi_anti_join.out @@ -39,3 +39,12 @@ 3 3 10 10 +-- !join_mark_join1 -- +1 1 +2 2 +3 3 +10 10 + +-- !join_mark_join2 -- +10 10 + diff --git a/regression-test/data/query_p0/join/test_nestedloop_semi_anti_join.out b/regression-test/data/query_p0/join/test_nestedloop_semi_anti_join.out index 563fc605a96..ecdfc8f8a28 100644 --- a/regression-test/data/query_p0/join/test_nestedloop_semi_anti_join.out +++ b/regression-test/data/query_p0/join/test_nestedloop_semi_anti_join.out @@ -39,6 +39,15 @@ 3 3 10 10 +-- !join_mark_join1 -- +1 1 +2 2 +3 3 +10 10 + +-- !join_mark_join2 -- +10 10 + -- !nlj_left_semi -- 1 diff --git a/regression-test/suites/nereids_p0/join/test_nestedloop_semi_anti_join.groovy b/regression-test/suites/nereids_p0/join/test_nestedloop_semi_anti_join.groovy index cb7f4144b8b..81e6334bf02 100644 --- a/regression-test/suites/nereids_p0/join/test_nestedloop_semi_anti_join.groovy +++ b/regression-test/suites/nereids_p0/join/test_nestedloop_semi_anti_join.groovy @@ -78,6 +78,14 @@ suite("test_nestedloop_semi_anti_join", "nereids_p0") { qt_join """ select * from ${tbl1} where user_id not in (select user_id from ${tbl2} where ${tbl1}.user_id > ${tbl2}.user_id) order by ${tbl1}.user_id; """ + + qt_join_mark_join1 """ + select * from ${tbl1} where exists (select * from ${tbl2} where ${tbl1}.user_id > ${tbl2}.user_id) or ${tbl1}.user_id2 > 3 order by ${tbl1}.user_id; + """ + + qt_join_mark_join2 """ + select * from ${tbl1} where not exists (select * from ${tbl2} where ${tbl1}.user_id > ${tbl2}.user_id) or ${tbl1}.user_id2 > 3 order by ${tbl1}.user_id; + """ sql "DROP TABLE IF EXISTS ${tbl1}" sql "DROP TABLE IF EXISTS ${tbl2}" } diff --git a/regression-test/suites/query_p0/join/test_nestedloop_semi_anti_join.groovy b/regression-test/suites/query_p0/join/test_nestedloop_semi_anti_join.groovy index 61c6538217c..47dfbc02257 100644 --- a/regression-test/suites/query_p0/join/test_nestedloop_semi_anti_join.groovy +++ b/regression-test/suites/query_p0/join/test_nestedloop_semi_anti_join.groovy @@ -76,6 +76,15 @@ suite("test_nestedloop_semi_anti_join", "query_p0") { qt_join """ select * from ${tbl1} where user_id not in (select user_id from ${tbl2} where ${tbl1}.user_id > ${tbl2}.user_id) order by ${tbl1}.user_id; """ + + qt_join_mark_join1 """ + select * from ${tbl1} where exists (select * from ${tbl2} where ${tbl1}.user_id > ${tbl2}.user_id) or ${tbl1}.user_id2 > 3 order by ${tbl1}.user_id; + """ + + qt_join_mark_join2 """ + select * from ${tbl1} where not exists (select * from ${tbl2} where ${tbl1}.user_id > ${tbl2}.user_id) or ${tbl1}.user_id2 > 3 order by ${tbl1}.user_id; + """ + sql "DROP TABLE IF EXISTS ${tbl1}" sql """ --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org