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

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


The following commit(s) were added to refs/heads/branch-4.1 by this push:
     new c9b8123d7f7 branch-4.1: [fix](be) Fix TIMESTAMPTZ values in COALESCE 
#66689 (#67055)
c9b8123d7f7 is described below

commit c9b8123d7f7c6e4f664c60e064571d9749a1234a
Author: github-actions[bot] 
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Tue Aug 25 09:48:45 2026 +0800

    branch-4.1: [fix](be) Fix TIMESTAMPTZ values in COALESCE #66689 (#67055)
    
    Cherry-picked from #66689
    
    Co-authored-by: Mryange <[email protected]>
---
 be/src/exprs/vcondition_expr.cpp                   |  9 ++--
 .../timestamptz/test_timestamptz_coalesce.out      |  5 +++
 .../timestamptz/test_timestamptz_coalesce.groovy   | 51 ++++++++++++++++++++++
 3 files changed, 59 insertions(+), 6 deletions(-)

diff --git a/be/src/exprs/vcondition_expr.cpp b/be/src/exprs/vcondition_expr.cpp
index 60ae59147d1..d126511b033 100644
--- a/be/src/exprs/vcondition_expr.cpp
+++ b/be/src/exprs/vcondition_expr.cpp
@@ -552,12 +552,9 @@ void insert_result_data(MutableColumnPtr& result_column, 
ColumnPtr& argument_col
                         const UInt8* __restrict null_map_data, UInt8* 
__restrict filled_flag,
                         const size_t input_rows_count) {
     if (result_column->size() == 0 && input_rows_count) {
-        result_column->resize(input_rows_count);
-        auto* __restrict result_raw_data =
-                
assert_cast<ColumnType*>(result_column.get())->get_data().data();
-        for (int i = 0; i < input_rows_count; i++) {
-            result_raw_data[i] = {};
-        }
+        // The branchless accumulation below requires an all-zero buffer. Do 
not value-initialize
+        // date-like types here because their default values may have non-zero 
packed bits.
+        
assert_cast<ColumnType*>(result_column.get())->get_data().resize_fill(input_rows_count);
     }
     auto* __restrict result_raw_data =
             assert_cast<ColumnType*>(result_column.get())->get_data().data();
diff --git 
a/regression-test/data/datatype_p0/timestamptz/test_timestamptz_coalesce.out 
b/regression-test/data/datatype_p0/timestamptz/test_timestamptz_coalesce.out
new file mode 100644
index 00000000000..935cebcf673
--- /dev/null
+++ b/regression-test/data/datatype_p0/timestamptz/test_timestamptz_coalesce.out
@@ -0,0 +1,5 @@
+-- This file is automatically generated. You should know what you did if you 
want to edit this
+-- !coalesce_nullable_timestamptz --
+1      2024-01-01 08:00:00+08:00       2024-01-01 08:00:00+08:00
+2      \N      2024-01-01 08:00:00+08:00
+
diff --git 
a/regression-test/suites/datatype_p0/timestamptz/test_timestamptz_coalesce.groovy
 
b/regression-test/suites/datatype_p0/timestamptz/test_timestamptz_coalesce.groovy
new file mode 100644
index 00000000000..49dfadcad41
--- /dev/null
+++ 
b/regression-test/suites/datatype_p0/timestamptz/test_timestamptz_coalesce.groovy
@@ -0,0 +1,51 @@
+// 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_timestamptz_coalesce", "datatype_p0") {
+    sql "SET time_zone = 'Asia/Shanghai'"
+    sql "SET enable_strict_cast = false"
+    sql "SET short_circuit_evaluation = false"
+
+    sql "DROP TABLE IF EXISTS timestamptz_coalesce_check"
+    sql """
+        CREATE TABLE timestamptz_coalesce_check (
+            row_id INT,
+            ts_value TIMESTAMPTZ NULL
+        )
+        DUPLICATE KEY(row_id)
+        DISTRIBUTED BY HASH(row_id) BUCKETS 1
+        PROPERTIES("replication_num" = "1")
+    """
+
+    sql """
+        INSERT INTO timestamptz_coalesce_check VALUES
+            (1, '2024-01-01 00:00:00+00:00'),
+            (2, NULL)
+    """
+
+    order_qt_coalesce_nullable_timestamptz """
+        SELECT
+            row_id,
+            ts_value,
+            COALESCE(
+                ts_value,
+                CAST('2024-01-01 00:00:00+00:00' AS TIMESTAMPTZ)
+            ) AS result_value
+        FROM timestamptz_coalesce_check
+        ORDER BY row_id
+    """
+}


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

Reply via email to