diff --git a/be/src/vec/common/hash_table/join_hash_table.h b/be/src/vec/common/hash_table/join_hash_table.h index d2d6dfc2ed9acc..c83f8d17c2709b 100644 --- a/be/src/vec/common/hash_table/join_hash_table.h +++ b/be/src/vec/common/hash_table/join_hash_table.h @@ -90,11 +90,11 @@ class JoinHashTable { int probe_idx, uint32_t build_idx, int probe_rows, uint32_t* __restrict probe_idxs, bool& probe_visited, uint32_t* __restrict build_idxs) { - if constexpr (JoinOpType == TJoinOp::NULL_AWARE_LEFT_ANTI_JOIN) { + if constexpr (JoinOpType == TJoinOp::NULL_AWARE_LEFT_ANTI_JOIN || + JoinOpType == TJoinOp::NULL_AWARE_LEFT_SEMI_JOIN) { if (_empty_build_side) { - return _process_null_aware_left_anti_join_for_empty_build_side< - JoinOpType, with_other_conjuncts, is_mark_join>(probe_idx, probe_rows, - probe_idxs, build_idxs); + return _process_null_aware_left_half_join_for_empty_build_side( + probe_idx, probe_rows, probe_idxs, build_idxs); } } @@ -247,11 +247,12 @@ class JoinHashTable { } private: - template - auto _process_null_aware_left_anti_join_for_empty_build_side(int probe_idx, int probe_rows, + template + auto _process_null_aware_left_half_join_for_empty_build_side(int probe_idx, int probe_rows, uint32_t* __restrict probe_idxs, uint32_t* __restrict build_idxs) { - static_assert(JoinOpType == TJoinOp::NULL_AWARE_LEFT_ANTI_JOIN); + static_assert(JoinOpType == TJoinOp::NULL_AWARE_LEFT_ANTI_JOIN || + JoinOpType == TJoinOp::NULL_AWARE_LEFT_SEMI_JOIN); auto matched_cnt = 0; const auto batch_size = max_batch_size; 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 895bd327f34ea1..f6b5f3c5153c24 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 @@ -18,3 +18,8 @@ -- !select_2 -- +-- !semi_emtpy_right_false -- +\N false +1 false +3 false + 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 a414e860f761a4..9260ff81ab6a72 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 @@ -85,4 +85,15 @@ suite("test_null_aware_left_anti_join") { FROM test_null_aware_left_anti_join2 AS t2 ) AND t1.`k1` IN (1, 2, 3, 5, 7);""" + + // In left semi join, if right side is empty, the result should not be null but false. + qt_semi_emtpy_right_false """ + select + t1.k1, + t1.k1 in ( + select k1 from ${tableName2} t2 where t2.k1 > 2 + ) value + from ${tableName1} t1 + order by 1, 2; + """ }