This is an automated email from the ASF dual-hosted git repository.

yiguolei 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 91229bb87d [Bug](makr join) Fix mark join with other conjuncts (#16435)
91229bb87d is described below

commit 91229bb87da5b34838039814497b47e39f2447b4
Author: Gabriel <[email protected]>
AuthorDate: Tue Feb 7 09:31:41 2023 +0800

    [Bug](makr join) Fix mark join with other conjuncts (#16435)
---
 .../vec/exec/join/process_hash_table_probe_impl.h  | 24 ++++++++++++++++------
 .../correctness/test_subquery_in_disjunction.out   | 23 +++++++++++++++++++++
 .../test_subquery_in_disjunction.groovy            | 24 ++++++++++++++++++----
 .../suites/datatype_p0/date/test_date_exprs.groovy |  2 +-
 4 files changed, 62 insertions(+), 11 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 238a3de0b4..cde05d72ae 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
@@ -547,6 +547,19 @@ Status 
ProcessHashTableProbe<JoinOpType>::do_process_with_other_join_conjuncts(
                     _build_block_rows.emplace_back(-1);
                 }
                 ++current_offset;
+            } else if constexpr (JoinOpType == TJoinOp::LEFT_SEMI_JOIN) {
+                if (is_mark_join) {
+                    same_to_prev.emplace_back(false);
+                    visited_map.emplace_back(nullptr);
+                    if (LIKELY(current_offset < _build_block_rows.size())) {
+                        _build_block_offsets[current_offset] = -1;
+                        _build_block_rows[current_offset] = -1;
+                    } else {
+                        _build_block_offsets.emplace_back(-1);
+                        _build_block_rows.emplace_back(-1);
+                    }
+                    ++current_offset;
+                }
             } else {
                 // other join, no nothing
             }
@@ -686,18 +699,17 @@ Status 
ProcessHashTableProbe<JoinOpType>::do_process_with_other_join_conjuncts(
                 }
 
                 if (is_mark_join) {
-                    auto& matched_map =
-                            
assert_cast<doris::vectorized::ColumnVector<UInt8>&>(
-                                    
*(output_block->get_by_position(output_block->columns() - 1)
-                                              .column->assume_mutable()))
-                                    .get_data();
+                    auto& matched_map = 
assert_cast<doris::vectorized::ColumnVector<UInt8>&>(
+                                                
*(output_block->get_by_position(num_cols - 1)
+                                                          
.column->assume_mutable()))
+                                                .get_data();
                     for (int i = 1; i < same_to_prev.size(); ++i) {
                         if (!same_to_prev[i]) {
                             matched_map.push_back(!filter_map[i - 1]);
                             filter_map[i - 1] = true;
                         }
                     }
-                    matched_map.push_back(filter_map[filter_map.size() - 1]);
+                    matched_map.push_back(!filter_map[filter_map.size() - 1]);
                     filter_map[filter_map.size() - 1] = true;
                 } else {
                     // Same to the semi join, but change the last value to 
opposite value
diff --git a/regression-test/data/correctness/test_subquery_in_disjunction.out 
b/regression-test/data/correctness/test_subquery_in_disjunction.out
index 80cd2373bd..5225575b3d 100644
--- a/regression-test/data/correctness/test_subquery_in_disjunction.out
+++ b/regression-test/data/correctness/test_subquery_in_disjunction.out
@@ -25,13 +25,36 @@
 100    200     300
 
 -- !hash_join_with_other_conjuncts1 --
+1      2       3
 
 -- !hash_join_with_other_conjuncts2 --
+1      2       3
 10     20      30
 
 -- !hash_join_with_other_conjuncts3 --
+1      2       3
 10     20      30
 
 -- !hash_join_with_other_conjuncts4 --
+1      2       3
+10     20      30
+
+-- !hash_join_with_other_conjuncts5 --
+1      2       3
 10     20      30
+100    200     300
+
+-- !hash_join_with_other_conjuncts6 --
+1      2       3
+100    200     300
+
+-- !hash_join_with_other_conjuncts7 --
+1      2       3
+10     20      30
+100    200     300
+
+-- !hash_join_with_other_conjuncts8 --
+1      2       3
+10     20      30
+100    200     300
 
diff --git 
a/regression-test/suites/correctness/test_subquery_in_disjunction.groovy 
b/regression-test/suites/correctness/test_subquery_in_disjunction.groovy
index b74b32f56a..5b7fd84abf 100644
--- a/regression-test/suites/correctness/test_subquery_in_disjunction.groovy
+++ b/regression-test/suites/correctness/test_subquery_in_disjunction.groovy
@@ -82,18 +82,34 @@ suite("test_subquery_in_disjunction") {
     """
 
     qt_hash_join_with_other_conjuncts1 """
-        SELECT * FROM test_sq_dj1 WHERE c1 IN (SELECT c1 FROM test_sq_dj2 
WHERE test_sq_dj1.c1 > test_sq_dj2.c2) OR c1 < 10;
+        SELECT * FROM test_sq_dj1 WHERE c1 IN (SELECT c1 FROM test_sq_dj2 
WHERE test_sq_dj1.c1 > test_sq_dj2.c2) OR c1 < 10 ORDER BY c1;
     """
 
     qt_hash_join_with_other_conjuncts2 """
-        SELECT * FROM test_sq_dj1 WHERE c1 IN (SELECT c1 FROM test_sq_dj2 
WHERE test_sq_dj1.c1 < test_sq_dj2.c2) OR c1 < 10;
+        SELECT * FROM test_sq_dj1 WHERE c1 IN (SELECT c1 FROM test_sq_dj2 
WHERE test_sq_dj1.c1 < test_sq_dj2.c2) OR c1 < 10 ORDER BY c1;
     """
 
     qt_hash_join_with_other_conjuncts3 """
-        SELECT * FROM test_sq_dj1 WHERE c1 IN (SELECT c1 FROM test_sq_dj2 
WHERE test_sq_dj1.c1 > test_sq_dj2.c2) OR c1 < 11;
+        SELECT * FROM test_sq_dj1 WHERE c1 IN (SELECT c1 FROM test_sq_dj2 
WHERE test_sq_dj1.c1 > test_sq_dj2.c2) OR c1 < 11 ORDER BY c1;
     """
 
     qt_hash_join_with_other_conjuncts4 """
-        SELECT * FROM test_sq_dj1 WHERE c1 IN (SELECT c1 FROM test_sq_dj2 
WHERE test_sq_dj1.c1 < test_sq_dj2.c2) OR c1 < 11;
+        SELECT * FROM test_sq_dj1 WHERE c1 IN (SELECT c1 FROM test_sq_dj2 
WHERE test_sq_dj1.c1 < test_sq_dj2.c2) OR c1 < 11 ORDER BY c1;
+    """
+
+    qt_hash_join_with_other_conjuncts5 """
+        SELECT * FROM test_sq_dj1 WHERE c1 NOT IN (SELECT c1 FROM test_sq_dj2 
WHERE test_sq_dj1.c1 > test_sq_dj2.c2) OR c1 < 10 ORDER BY c1;
+    """
+
+    qt_hash_join_with_other_conjuncts6 """
+        SELECT * FROM test_sq_dj1 WHERE c1 NOT IN (SELECT c1 FROM test_sq_dj2 
WHERE test_sq_dj1.c1 < test_sq_dj2.c2) OR c1 < 10 ORDER BY c1;
+    """
+
+    qt_hash_join_with_other_conjuncts7 """
+        SELECT * FROM test_sq_dj1 WHERE c1 NOT IN (SELECT c1 FROM test_sq_dj2 
WHERE test_sq_dj1.c1 > test_sq_dj2.c2) OR c1 < 11 ORDER BY c1;
+    """
+
+    qt_hash_join_with_other_conjuncts8 """
+        SELECT * FROM test_sq_dj1 WHERE c1 NOT IN (SELECT c1 FROM test_sq_dj2 
WHERE test_sq_dj1.c1 < test_sq_dj2.c2) OR c1 < 11 ORDER BY c1;
     """
 }
diff --git a/regression-test/suites/datatype_p0/date/test_date_exprs.groovy 
b/regression-test/suites/datatype_p0/date/test_date_exprs.groovy
index b77bb85bf5..6fb62b86d1 100644
--- a/regression-test/suites/datatype_p0/date/test_date_exprs.groovy
+++ b/regression-test/suites/datatype_p0/date/test_date_exprs.groovy
@@ -27,7 +27,7 @@ suite("test_date_exprs") {
     qt_sql1 """ select dt
              from
              (
-             select cast(k1 as datev2) as dt
+             select cast(k1 as date) as dt
              from ${tbName}
              ) r; """
     qt_sql2 """ select dt


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to