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
The following commit(s) were added to refs/heads/branch-2.1 by this push:
new 4b7c2eaa7d5 [branch-2.1](fix) fix incorrect result of hash join with
const column (#45630)
4b7c2eaa7d5 is described below
commit 4b7c2eaa7d5bfbe6bc34de595d2193255b89e8de
Author: Xujian Duan <[email protected]>
AuthorDate: Thu Dec 19 19:14:38 2024 +0800
[branch-2.1](fix) fix incorrect result of hash join with const column
(#45630)
---
be/src/vec/runtime/partitioner.cpp | 6 +-
.../data/query_p0/join/test_join_with_const.out | 9 +++
.../query_p0/join/test_join_with_const.groovy | 71 ++++++++++++++++++++++
3 files changed, 85 insertions(+), 1 deletion(-)
diff --git a/be/src/vec/runtime/partitioner.cpp
b/be/src/vec/runtime/partitioner.cpp
index bbb6ebfc1a8..183b3cac2f9 100644
--- a/be/src/vec/runtime/partitioner.cpp
+++ b/be/src/vec/runtime/partitioner.cpp
@@ -43,7 +43,11 @@ Status Partitioner<HashValueType,
ChannelIds>::do_partitioning(RuntimeState* sta
RETURN_IF_ERROR(_get_partition_column_result(block, result));
}
for (int j = 0; j < result_size; ++j) {
-
_do_hash(unpack_if_const(block->get_by_position(result[j]).column).first,
hashes, j);
+ const auto& [col, is_const] =
unpack_if_const(block->get_by_position(result[j]).column);
+ if (is_const) {
+ continue;
+ }
+ _do_hash(col, hashes, j);
}
for (int i = 0; i < rows; i++) {
diff --git a/regression-test/data/query_p0/join/test_join_with_const.out
b/regression-test/data/query_p0/join/test_join_with_const.out
new file mode 100644
index 00000000000..1f62548a249
--- /dev/null
+++ b/regression-test/data/query_p0/join/test_join_with_const.out
@@ -0,0 +1,9 @@
+-- This file is automatically generated. You should know what you did if you
want to edit this
+-- !sql1 --
+0 2024-10-31 1 \N \N \N
+0 2024-11-01 1 0 2024-11-01 2
+
+-- !sql1 --
+0 2024-10-31 1 \N \N \N
+0 2024-11-01 1 0 2024-11-01 2
+
diff --git a/regression-test/suites/query_p0/join/test_join_with_const.groovy
b/regression-test/suites/query_p0/join/test_join_with_const.groovy
new file mode 100644
index 00000000000..6cdcde7aece
--- /dev/null
+++ b/regression-test/suites/query_p0/join/test_join_with_const.groovy
@@ -0,0 +1,71 @@
+
+// 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_join_with_const", "query,p0") {
+ def left_table = "left_table"
+ def right_table = "right_table"
+ sql " drop table if exists ${left_table}; ";
+ sql " drop table if exists ${right_table}; ";
+ sql """
+ create table ${left_table} (c1 datev2, c2 bigint sum)
+ aggregate key (c1)
+ DISTRIBUTED BY HASH(c1)
+ BUCKETS 3
+ properties ("replication_num" = "1");
+ """
+ sql """
+ create table ${right_table} (c1 datev2, c2 bigint sum)
+ aggregate key (c1)
+ DISTRIBUTED BY HASH(c1)
+ BUCKETS 3
+ properties ("replication_num" = "1");
+ """
+
+ sql """ insert into ${left_table} values ("2024-10-31", 1), ("2024-11-01",
1); """
+ sql """ insert into ${right_table} values ("2024-11-01", 2); """
+
+ def join_sql_str = """
+ select
+ *
+ from
+ (
+ select 0 z, c1, sum(c2) c2
+ from ${left_table}
+ group by 1, 2
+ ) t1
+ FULL JOIN [shuffle]
+ (
+ select 0 z, c1, sum(c2) c2
+ from ${right_table}
+ group by 1, 2
+ ) t2
+ on t1.z = t2.z
+ and t1.c1 = t2.c1
+ order by t1.c1
+ """
+
+ sql "set enable_nereids_planner = false;"
+ qt_sql1 "${join_sql_str}"
+
+ sql "set enable_nereids_planner = true;"
+ qt_sql1 "${join_sql_str}"
+
+ sql "drop table ${left_table}"
+ sql "drop table ${right_table}"
+
+}
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]