You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by yi...@apache.org on 2023/06/19 04:28:20 UTC

[doris] branch branch-1.2-lts updated: [fix](leftjoin) fix bug of left and full join with other conjuncts (#20947)

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

yiguolei pushed a commit to branch branch-1.2-lts
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/branch-1.2-lts by this push:
     new d43a2fa220 [fix](leftjoin) fix bug of left and full join with other conjuncts (#20947)
d43a2fa220 is described below

commit d43a2fa22027f3727e118fecd25f0f49995116d8
Author: TengJianPing <18...@users.noreply.github.com>
AuthorDate: Mon Jun 19 12:28:15 2023 +0800

    [fix](leftjoin) fix bug of left and full join with other conjuncts (#20947)
    
    Fix bug of left and full outer join with other conjuncts. When equal matched row count of a probe row exceed batch_size, some times the _join_node->_is_any_probe_match_row_output flag is not set correcty, which result in outputing extra rows for the probe row.
---
 .../vec/exec/join/process_hash_table_probe_impl.h  |  3 +-
 .../query_p0/join/test_full_join_batch_size.out    |  9 ++++
 .../query_p0/join/test_left_join_batch_size.out    |  6 +++
 .../query_p0/join/test_full_join_batch_size.groovy | 54 ++++++++++++++++++++++
 .../query_p0/join/test_left_join_batch_size.groovy | 54 ++++++++++++++++++++++
 5 files changed, 125 insertions(+), 1 deletion(-)

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 93ef553b0d..e119d54681 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
@@ -1011,7 +1011,8 @@ void ProcessHashTableProbe<JoinOpType>::_process_splited_equal_matched_tuples(
             *visited_map[i] |= other_hit;
         }
     }
-    _join_node->_is_any_probe_match_row_output |= simd::contain_byte(filter_map, row_count, 1);
+    _join_node->_is_any_probe_match_row_output |=
+            simd::contain_byte(filter_map + start_row_idx, row_count, 1);
 }
 
 template <int JoinOpType>
diff --git a/regression-test/data/query_p0/join/test_full_join_batch_size.out b/regression-test/data/query_p0/join/test_full_join_batch_size.out
new file mode 100644
index 0000000000..21780c4776
--- /dev/null
+++ b/regression-test/data/query_p0/join/test_full_join_batch_size.out
@@ -0,0 +1,9 @@
+-- This file is automatically generated. You should know what you did if you want to edit this
+-- !sql1 --
+\N	\N	1	211
+\N	\N	1	311
+\N	\N	1	411
+1	11	1	\N
+1	111	1	\N
+1	1111	1	\N
+
diff --git a/regression-test/data/query_p0/join/test_left_join_batch_size.out b/regression-test/data/query_p0/join/test_left_join_batch_size.out
new file mode 100644
index 0000000000..eff73aae80
--- /dev/null
+++ b/regression-test/data/query_p0/join/test_left_join_batch_size.out
@@ -0,0 +1,6 @@
+-- This file is automatically generated. You should know what you did if you want to edit this
+-- !sql1 --
+1	11	1	\N
+1	111	1	\N
+1	1111	1	\N
+
diff --git a/regression-test/suites/query_p0/join/test_full_join_batch_size.groovy b/regression-test/suites/query_p0/join/test_full_join_batch_size.groovy
new file mode 100644
index 0000000000..6ea3923fa2
--- /dev/null
+++ b/regression-test/suites/query_p0/join/test_full_join_batch_size.groovy
@@ -0,0 +1,54 @@
+// 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_full_join_batch_size", "query,p0") {
+    sql " drop table if exists test_left_join_batch_size_l; ";
+    sql " drop table if exists test_left_join_batch_size_r; ";
+    sql """
+        create table test_left_join_batch_size_l (
+            k1 int,
+            v1 int
+        ) distributed by hash(k1) buckets 3
+        properties("replication_num" = "1");
+    """
+    sql """
+        create table test_left_join_batch_size_r (
+            k1 int,
+            v1 int
+        ) distributed by hash(k1) buckets 3
+        properties("replication_num" = "1");
+    """
+
+    sql """ insert into test_left_join_batch_size_l values (1, 11), (1, 111), (1, 1111) """
+    sql """ insert into test_left_join_batch_size_r values (1, null), (1, 211), (1, 311), (1, 411) """
+
+    qt_sql1 """
+        select /*+SET_VAR(batch_size=3)*/
+               l.k1,
+               l.v1,
+               r.k1,
+               r.v1
+        from
+               test_left_join_batch_size_l l
+               full join test_left_join_batch_size_r r on (
+                      r.v1 = 0
+                      or r.v1 is null
+               )
+               and l.k1 = r.k1
+                order by l.k1, l.v1, r.k1, r.v1;
+    """
+}
\ No newline at end of file
diff --git a/regression-test/suites/query_p0/join/test_left_join_batch_size.groovy b/regression-test/suites/query_p0/join/test_left_join_batch_size.groovy
new file mode 100644
index 0000000000..6cff8071a1
--- /dev/null
+++ b/regression-test/suites/query_p0/join/test_left_join_batch_size.groovy
@@ -0,0 +1,54 @@
+// 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_left_join_batch_size", "query,p0") {
+    sql " drop table if exists test_left_join_batch_size_l; ";
+    sql " drop table if exists test_left_join_batch_size_r; ";
+    sql """
+        create table test_left_join_batch_size_l (
+            k1 int,
+            v1 int
+        ) distributed by hash(k1) buckets 3
+        properties("replication_num" = "1");
+    """
+    sql """
+        create table test_left_join_batch_size_r (
+            k1 int,
+            v1 int
+        ) distributed by hash(k1) buckets 3
+        properties("replication_num" = "1");
+    """
+
+    sql """ insert into test_left_join_batch_size_l values (1, 11), (1, 111), (1, 1111) """
+    sql """ insert into test_left_join_batch_size_r values (1, null), (1, 211), (1, 311), (1, 411) """
+
+    qt_sql1 """
+        select /*+SET_VAR(batch_size=3)*/
+               l.k1,
+               l.v1,
+               r.k1,
+               r.v1
+        from
+               test_left_join_batch_size_l l
+               left join test_left_join_batch_size_r r on (
+                      r.v1 = 0
+                      or r.v1 is null
+               )
+               and l.k1 = r.k1
+                order by l.k1, l.v1, r.k1, r.v1;
+    """
+}
\ No newline at end of file


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org