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

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


The following commit(s) were added to refs/heads/branch-4.0 by this push:
     new 38d337769d3 branch-4.0: [Fix](function) Fix wrong nullable of 
floor/ceil functions #57238 (#57244)
38d337769d3 is described below

commit 38d337769d3f74c5c213afc344aacd22dbb2b6e1
Author: github-actions[bot] 
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Thu Oct 23 10:37:11 2025 +0800

    branch-4.0: [Fix](function) Fix wrong nullable of floor/ceil functions 
#57238 (#57244)
    
    Cherry-picked from #57238
    
    Co-authored-by: zclllyybb <[email protected]>
---
 be/src/vec/functions/function_datetime_floor_ceil.cpp        | 2 +-
 be/src/vec/functions/function_other_types_to_date.cpp        | 2 +-
 regression-test/suites/correctness_p0/test_time_round.groovy | 6 ++++++
 3 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/be/src/vec/functions/function_datetime_floor_ceil.cpp 
b/be/src/vec/functions/function_datetime_floor_ceil.cpp
index d8516763f5f..a3f92289475 100644
--- a/be/src/vec/functions/function_datetime_floor_ceil.cpp
+++ b/be/src/vec/functions/function_datetime_floor_ceil.cpp
@@ -256,7 +256,7 @@ public:
             }
         }
 
-        if (block.get_by_position(arguments[0]).type->is_nullable()) {
+        if (block.get_by_position(result).type->is_nullable()) {
             block.replace_by_position(
                     result,
                     ColumnNullable::create(std::move(col_to), 
std::move(result_null_map_column)));
diff --git a/be/src/vec/functions/function_other_types_to_date.cpp 
b/be/src/vec/functions/function_other_types_to_date.cpp
index 56b75d39cb8..2c35d4138bc 100644
--- a/be/src/vec/functions/function_other_types_to_date.cpp
+++ b/be/src/vec/functions/function_other_types_to_date.cpp
@@ -534,7 +534,7 @@ public:
         }
 
         // Wrap result in nullable column only if input has nullable arguments
-        if (block.get_by_position(arguments[0]).type->is_nullable()) {
+        if (block.get_by_position(result).type->is_nullable()) {
             block.replace_by_position(result,
                                       
ColumnNullable::create(std::move(res_column),
                                                              
std::move(result_null_map_column)));
diff --git a/regression-test/suites/correctness_p0/test_time_round.groovy 
b/regression-test/suites/correctness_p0/test_time_round.groovy
index 45caf3a5c13..b747d894776 100644
--- a/regression-test/suites/correctness_p0/test_time_round.groovy
+++ b/regression-test/suites/correctness_p0/test_time_round.groovy
@@ -396,6 +396,12 @@ suite("test_time_round") {
     testFoldConst("select minute_ceil('2025-09-10 12:34:56.45', 5)")
     testFoldConst("select minute_ceil('2025-09-10 12:34:56.12345', '2025-09-10 
12:30:00.678')")
     testFoldConst("select minute_ceil('2025-09-10 12:34:56.9', 10, '2025-09-10 
12:30:00.234567')")
+    testFoldConst("""select minute_ceil(CAST('2021-12-31 12:23:34' AS 
DATETIMEV2(0)),
+                        nullable(CAST('2021-12-31 12:23:34' AS 
DATETIMEV2(0))));""")
+    testFoldConst("""select minute_ceil(nullable(CAST('2021-12-31 12:23:34' AS 
DATETIMEV2(0))),
+                        CAST('2021-12-31 12:23:34' AS DATETIMEV2(0)));""")
+    testFoldConst("""select minute_ceil(nullable(CAST('2021-12-31 12:23:34' AS 
DATETIMEV2(0))),
+                        nullable(CAST('2021-12-31 12:23:34' AS 
DATETIMEV2(0))));""")
 
     testFoldConst("select minute_floor('2025-09-10 12:34:56')")
     testFoldConst("select minute_floor('2025-09-10 12:34:56', 5)")


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

Reply via email to