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 ac167f493be [fix](join) fix decimal overflow caused by left outer join 
(#28221)
ac167f493be is described below

commit ac167f493be3bad3c7fe46e48d87abbb0da8baeb
Author: TengJianPing <18241664+jackte...@users.noreply.github.com>
AuthorDate: Mon Dec 11 11:51:05 2023 +0800

    [fix](join) fix decimal overflow caused by left outer join (#28221)
    
    For left outer join or full outer join, when build side data is empty, null 
data is output for build side, but nested column data of nullable column is not 
properly initialized, which may cause decimal arithmetic overflow
---
 be/src/vec/exec/join/vhash_join_node.cpp           |  2 +-
 .../data/datatype_p0/decimalv3/fix-overflow.out    |  4 +++
 .../datatype_p0/decimalv3/fix-overflow.groovy      | 34 ++++++++++++++++++++++
 .../decimalv3/test_arithmetic_expressions.groovy   |  1 +
 4 files changed, 40 insertions(+), 1 deletion(-)

diff --git a/be/src/vec/exec/join/vhash_join_node.cpp 
b/be/src/vec/exec/join/vhash_join_node.cpp
index aaa591c110b..65615d4e623 100644
--- a/be/src/vec/exec/join/vhash_join_node.cpp
+++ b/be/src/vec/exec/join/vhash_join_node.cpp
@@ -367,7 +367,7 @@ Status HashJoinNode::pull(doris::RuntimeState* state, 
vectorized::Block* output_
              (_join_op != TJoinOp::LEFT_ANTI_JOIN) && i < 
_right_output_slot_flags.size(); ++i) {
             auto type = remove_nullable(_right_table_data_types[i]);
             auto column = type->create_column();
-            column->resize(block_rows);
+            column->insert_many_defaults(block_rows);
             auto null_map_column = ColumnVector<UInt8>::create(block_rows, 1);
             auto nullable_column =
                     ColumnNullable::create(std::move(column), 
std::move(null_map_column));
diff --git a/regression-test/data/datatype_p0/decimalv3/fix-overflow.out 
b/regression-test/data/datatype_p0/decimalv3/fix-overflow.out
new file mode 100644
index 00000000000..4bd52d46e49
--- /dev/null
+++ b/regression-test/data/datatype_p0/decimalv3/fix-overflow.out
@@ -0,0 +1,4 @@
+-- This file is automatically generated. You should know what you did if you 
want to edit this
+-- !sql --
+1.1    \N      \N
+
diff --git a/regression-test/suites/datatype_p0/decimalv3/fix-overflow.groovy 
b/regression-test/suites/datatype_p0/decimalv3/fix-overflow.groovy
new file mode 100644
index 00000000000..7b8ef17007d
--- /dev/null
+++ b/regression-test/suites/datatype_p0/decimalv3/fix-overflow.groovy
@@ -0,0 +1,34 @@
+// 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("fix-overflow") {
+    sql "set check_overflow_for_decimal=true;"
+    sql "drop table if exists fix_overflow_l;"
+    sql """
+        create table fix_overflow_l(k1 decimalv3(38,1)) distributed by 
hash(k1) properties("replication_num"="1");
+    """
+    sql "drop table if exists fix_overflow_r;"
+    sql """
+        create table fix_overflow_r(k1 decimalv3(38,1)) distributed by 
hash(k1) properties("replication_num"="1");
+    """
+    sql """
+        insert into fix_overflow_l values(1.1);
+    """
+    qt_sql """
+        select l.k1, r.k1, l.k1 * r.k1 from fix_overflow_l l left join 
fix_overflow_r r on l.k1=r.k1;
+    """
+}
diff --git 
a/regression-test/suites/datatype_p0/decimalv3/test_arithmetic_expressions.groovy
 
b/regression-test/suites/datatype_p0/decimalv3/test_arithmetic_expressions.groovy
index daf81e5e5f2..5936cf29b45 100644
--- 
a/regression-test/suites/datatype_p0/decimalv3/test_arithmetic_expressions.groovy
+++ 
b/regression-test/suites/datatype_p0/decimalv3/test_arithmetic_expressions.groovy
@@ -17,6 +17,7 @@
 
 suite("test_arithmetic_expressions") {
 
+    sql "set check_overflow_for_decimal=true;"
     sql "set enable_decimal256 = false;"
 
     sql "drop table if exists test_arithmetic_expressions"


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

Reply via email to