This is an automated email from the ASF dual-hosted git repository.
kxiao pushed a commit to branch branch-2.0
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-2.0 by this push:
new d1e88f4c763 [fix](join) incorrect result of left semi/anti join with
empty build side #28898 (#28914)
d1e88f4c763 is described below
commit d1e88f4c763dce29556aeb65fa30dd976e1f8bbe
Author: Jerry Hu <[email protected]>
AuthorDate: Sun Dec 24 20:47:26 2023 +0800
[fix](join) incorrect result of left semi/anti join with empty build side
#28898 (#28914)
---
.../vec/exec/join/process_hash_table_probe_impl.h | 5 ++++-
.../test_null_aware_left_anti_join.out | 12 ++++++++++
.../test_null_aware_left_anti_join.groovy | 26 ++++++++++++++++++----
3 files changed, 38 insertions(+), 5 deletions(-)
diff --git a/be/src/vec/exec/join/process_hash_table_probe_impl.h
b/be/src/vec/exec/join/process_hash_table_probe_impl.h
index 8edd21d835b..4fc8d2a1bbf 100644
--- a/be/src/vec/exec/join/process_hash_table_probe_impl.h
+++ b/be/src/vec/exec/join/process_hash_table_probe_impl.h
@@ -289,10 +289,13 @@ Status
ProcessHashTableProbe<JoinOpType>::do_process(HashTableType& hash_table_c
auto current_probe_index = probe_index;
if constexpr (JoinOpType == TJoinOp::LEFT_ANTI_JOIN ||
JoinOpType ==
TJoinOp::NULL_AWARE_LEFT_ANTI_JOIN) {
+ bool accept_null_value = JoinOpType ==
TJoinOp::NULL_AWARE_LEFT_ANTI_JOIN &&
+ hash_table_ctx.hash_table.size()
== 0;
if (is_mark_join) {
++current_offset;
bool null_result =
- (need_null_map_for_probe &&
(*null_map)[probe_index]) ||
+ (need_null_map_for_probe &&
(*null_map)[probe_index] &&
+ !accept_null_value) ||
(find_result.is_found() &&
_join_node->_has_null_in_build_side);
if (null_result) {
mark_column->insert_null();
diff --git
a/regression-test/data/correctness_p0/test_null_aware_left_anti_join.out
b/regression-test/data/correctness_p0/test_null_aware_left_anti_join.out
index d33e4e2947f..1365ad992e7 100644
--- a/regression-test/data/correctness_p0/test_null_aware_left_anti_join.out
+++ b/regression-test/data/correctness_p0/test_null_aware_left_anti_join.out
@@ -9,3 +9,15 @@
-- !select --
+-- !anti_emtpy_right --
+\N
+1
+3
+
+-- !semi_emtpy_right --
+
+-- !anti_emtpy_right2 --
+\N
+1
+3
+
diff --git
a/regression-test/suites/correctness_p0/test_null_aware_left_anti_join.groovy
b/regression-test/suites/correctness_p0/test_null_aware_left_anti_join.groovy
index f732b6bda58..eb8b075cf1d 100644
---
a/regression-test/suites/correctness_p0/test_null_aware_left_anti_join.groovy
+++
b/regression-test/suites/correctness_p0/test_null_aware_left_anti_join.groovy
@@ -60,11 +60,29 @@ suite("test_null_aware_left_anti_join") {
sql """ set parallel_pipeline_task_num=2; """
qt_select """ select ${tableName2}.k1 from ${tableName2} where k1 not in
(select ${tableName1}.k1 from ${tableName1}) order by ${tableName2}.k1; """
- sql """
- drop table if exists ${tableName2};
+ // In left anti join, if right side is empty, all rows(null included) of
left should be output.
+ qt_anti_emtpy_right """
+ select
+ *
+ from ${tableName1} t1 where k1 not in (
+ select k1 from ${tableName2} t2 where t2.k1 > 2
+ ) order by 1;
"""
- sql """
- drop table if exists ${tableName1};
+ // In left semi join, if right side is empty, no row should be output.
+ qt_semi_emtpy_right """
+ select
+ *
+ from ${tableName1} t1 where k1 in (
+ select k1 from ${tableName2} t2 where t2.k1 > 2
+ ) order by 1;
+ """
+
+ qt_anti_emtpy_right2 """
+ select
+ *
+ from ${tableName1} t1 where k1 not in (
+ select k1 from ${tableName2} t2 where t2.k1 > 2
+ ) or k1 > 5 order by 1;
"""
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]