diff --git a/be/src/vec/functions/function_datetime_floor_ceil.cpp b/be/src/vec/functions/function_datetime_floor_ceil.cpp index d8516763f5f592..a3f922894755b6 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 @@ class FunctionDateTimeFloorCeil : public IFunction { } } - 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 56b75d39cb88f2..2c35d4138bcaeb 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 @@ class FromDays : public IFunction { } // 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 45caf3a5c13e52..b747d894776f6b 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)")