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

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


The following commit(s) were added to refs/heads/branch-3.0 by this push:
     new 0c9f852a8ee [branch-3.0](column) Fix wrong nullmap initialization 
#51340 (#51339)
0c9f852a8ee is described below

commit 0c9f852a8ee16c14ecc5d82daadfa07aaa8b2bd1
Author: zclllyybb <[email protected]>
AuthorDate: Fri May 30 16:11:01 2025 +0800

    [branch-3.0](column) Fix wrong nullmap initialization #51340 (#51339)
    
    pick https://github.com/apache/doris/pull/51340
---
 be/src/vec/columns/column_vector.h                 |   6 ++++-
 be/src/vec/exprs/vbitmap_predicate.cpp             |   2 +-
 be/src/vec/exprs/vbloom_predicate.cpp              |   2 +-
 be/src/vec/exprs/vdirect_in_predicate.h            |   2 +-
 be/src/vec/functions/date_time_transforms.h        |   2 +-
 .../function_date_or_datetime_to_string.h          |   2 +-
 be/src/vec/functions/function_timestamp.cpp        |   5 +++-
 .../data/correctness_p0/test_nullmap.out           | Bin 0 -> 275 bytes
 .../suites/correctness_p0/test_nullmap.groovy      |  27 +++++++++++++++++++++
 9 files changed, 41 insertions(+), 7 deletions(-)

diff --git a/be/src/vec/columns/column_vector.h 
b/be/src/vec/columns/column_vector.h
index f3cdb7d2dbd..e3bf98118b1 100644
--- a/be/src/vec/columns/column_vector.h
+++ b/be/src/vec/columns/column_vector.h
@@ -143,7 +143,11 @@ public:
     using Container = PaddedPODArray<value_type>;
 
     ColumnVector() = default;
-    ColumnVector(const size_t n) : data(n) {}
+
+    // for column boolean, must have initial value!
+    ColumnVector(const size_t n)
+        requires requires { !std::is_same_v<T, UInt8>; }
+            : data(n) {}
     ColumnVector(const size_t n, const value_type x) : data(n, x) {}
     ColumnVector(const ColumnVector& src) : data(src.data.begin(), 
src.data.end()) {}
 
diff --git a/be/src/vec/exprs/vbitmap_predicate.cpp 
b/be/src/vec/exprs/vbitmap_predicate.cpp
index 8116311247b..ce62aa948bd 100644
--- a/be/src/vec/exprs/vbitmap_predicate.cpp
+++ b/be/src/vec/exprs/vbitmap_predicate.cpp
@@ -91,7 +91,7 @@ doris::Status 
vectorized::VBitmapPredicate::execute(vectorized::VExprContext* co
     }
     // call function
     size_t num_columns_without_result = block->columns();
-    auto res_data_column = ColumnVector<UInt8>::create(block->rows());
+    auto res_data_column = ColumnVector<UInt8>::create(block->rows(), 0);
 
     ColumnPtr argument_column =
             
block->get_by_position(arguments[0]).column->convert_to_full_column_if_const();
diff --git a/be/src/vec/exprs/vbloom_predicate.cpp 
b/be/src/vec/exprs/vbloom_predicate.cpp
index 08f891b0e56..e43c9092467 100644
--- a/be/src/vec/exprs/vbloom_predicate.cpp
+++ b/be/src/vec/exprs/vbloom_predicate.cpp
@@ -86,7 +86,7 @@ Status VBloomPredicate::execute(VExprContext* context, Block* 
block, int* result
     }
     // call function
     size_t num_columns_without_result = block->columns();
-    auto res_data_column = ColumnVector<UInt8>::create(block->rows());
+    auto res_data_column = ColumnVector<UInt8>::create(block->rows(), 0);
 
     ColumnPtr argument_column =
             
block->get_by_position(arguments[0]).column->convert_to_full_column_if_const();
diff --git a/be/src/vec/exprs/vdirect_in_predicate.h 
b/be/src/vec/exprs/vdirect_in_predicate.h
index 7abd43a5e02..edcc3c61564 100644
--- a/be/src/vec/exprs/vdirect_in_predicate.h
+++ b/be/src/vec/exprs/vdirect_in_predicate.h
@@ -72,7 +72,7 @@ private:
         }
 
         size_t num_columns_without_result = block->columns();
-        auto res_data_column = ColumnVector<UInt8>::create(block->rows());
+        auto res_data_column = ColumnVector<UInt8>::create(block->rows(), 0);
         ColumnPtr argument_column =
                 
block->get_by_position(arguments[0]).column->convert_to_full_column_if_const();
         size_t sz = argument_column->size();
diff --git a/be/src/vec/functions/date_time_transforms.h 
b/be/src/vec/functions/date_time_transforms.h
index beffaf54b4a..c23905ee19c 100644
--- a/be/src/vec/functions/date_time_transforms.h
+++ b/be/src/vec/functions/date_time_transforms.h
@@ -450,7 +450,7 @@ struct DateTimeTransformImpl {
         if (const auto* sources = 
check_and_get_column<ColumnVector<FromType>>(source_col.get())) {
             auto col_to = ColumnVector<ToType>::create();
             if (is_nullable) {
-                auto null_map = ColumnVector<UInt8>::create(input_rows_count);
+                auto null_map = ColumnVector<UInt8>::create(input_rows_count, 
false);
                 Op::vector(sources->get_data(), col_to->get_data(), 
null_map->get_data());
                 if (const auto* nullable_col = 
check_and_get_column<ColumnNullable>(
                             block.get_by_position(arguments[0]).column.get())) 
{
diff --git a/be/src/vec/functions/function_date_or_datetime_to_string.h 
b/be/src/vec/functions/function_date_or_datetime_to_string.h
index 53cb0199721..971215e7ec8 100644
--- a/be/src/vec/functions/function_date_or_datetime_to_string.h
+++ b/be/src/vec/functions/function_date_or_datetime_to_string.h
@@ -91,7 +91,7 @@ public:
         // Support all input of datetime is valind to make sure not null return
         if (sources) {
             if (is_nullable) {
-                auto null_map = ColumnVector<UInt8>::create(input_rows_count);
+                auto null_map = ColumnVector<UInt8>::create(input_rows_count, 
false);
                 TransformerToStringOneArgument<Transform>::vector(
                         context, sources->get_data(), col_res->get_chars(), 
col_res->get_offsets(),
                         null_map->get_data());
diff --git a/be/src/vec/functions/function_timestamp.cpp 
b/be/src/vec/functions/function_timestamp.cpp
index a0d6328a6a7..4dd3c77ebf0 100644
--- a/be/src/vec/functions/function_timestamp.cpp
+++ b/be/src/vec/functions/function_timestamp.cpp
@@ -713,7 +713,7 @@ struct UnixTimeStampStrImpl {
                 unpack_if_const(block.get_by_position(arguments[1]).column);
 
         auto col_result = ColumnDecimal<Decimal64>::create(input_rows_count, 
6);
-        auto null_map = ColumnVector<UInt8>::create(input_rows_count);
+        auto null_map = ColumnVector<UInt8>::create(input_rows_count, false);
         auto& col_result_data = col_result->get_data();
         auto& null_map_data = null_map->get_data();
 
@@ -723,6 +723,9 @@ struct UnixTimeStampStrImpl {
         const auto* col_source = assert_cast<const 
ColumnString*>(col_left.get());
         const auto* col_format = assert_cast<const 
ColumnString*>(col_right.get());
         for (int i = 0; i < input_rows_count; i++) {
+            if (null_map_data[i]) [[unlikely]] {
+                continue;
+            }
             StringRef source = col_source->get_data_at(index_check_const(i, 
source_const));
             StringRef fmt = col_format->get_data_at(index_check_const(i, 
format_const));
 
diff --git a/regression-test/data/correctness_p0/test_nullmap.out 
b/regression-test/data/correctness_p0/test_nullmap.out
new file mode 100644
index 00000000000..701d5892c89
Binary files /dev/null and 
b/regression-test/data/correctness_p0/test_nullmap.out differ
diff --git a/regression-test/suites/correctness_p0/test_nullmap.groovy 
b/regression-test/suites/correctness_p0/test_nullmap.groovy
new file mode 100644
index 00000000000..d22a946a8fa
--- /dev/null
+++ b/regression-test/suites/correctness_p0/test_nullmap.groovy
@@ -0,0 +1,27 @@
+// 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_nullmap", "query") {
+    sql """
+    drop table if exists tblx;
+    create table tblx(k1 int, k2 string) distributed by hash(k1) buckets 1 
properties("replication_num" = "1");
+    insert into tblx values(1, null), (2, "2022-10-10"), (3, "2023-10-10 
11:00:11"), (4, "abc");
+    """
+    qt_sql """select k2, unix_timestamp(k2, 'yyyy-MM-dd HH:mm:ss'), k21, 
unix_timestamp(k21, 'yyyy-MM-dd HH:mm:ss')
+    from (select k2, from_unixtime(unix_timestamp(k2, 'yyyy-MM-dd HH:mm:ss'), 
'yyyy-MM-dd HH:mm:ss') as k21 from tblx) y
+    order by 1,2,3,4"""
+}
\ No newline at end of file


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

Reply via email to