This is an automated email from the ASF dual-hosted git repository.
yiguolei pushed a commit to branch branch-4.2
in repository https://gitbox.apache.org/repos/asf/doris.git
commit 855c600cf88cf54761c58fa9a7812606a9e6a405
Author: github-actions[bot]
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Thu Sep 24 09:45:10 2026 +0800
branch-4.1: [fix](be) Preserve NULL propagation in date floor functions
#67951 (#68423)
Cherry-picked from #67951
Co-authored-by: Mryange <[email protected]>
---
be/src/exprs/function/function_datetime_floor_ceil.cpp | 12 ++++++++++++
be/test/exprs/function/function_time_test.cpp | 15 +++++++++++++++
2 files changed, 27 insertions(+)
diff --git a/be/src/exprs/function/function_datetime_floor_ceil.cpp
b/be/src/exprs/function/function_datetime_floor_ceil.cpp
index 101c552bb07..80b128ee6ec 100644
--- a/be/src/exprs/function/function_datetime_floor_ceil.cpp
+++ b/be/src/exprs/function/function_datetime_floor_ceil.cpp
@@ -176,6 +176,18 @@ public:
}
}
+ // A constant period is validated before the vectorized loop below.
Return early when every
+ // row is already NULL so NULL propagation takes precedence over
period validation.
+ if (input_rows_count > 0 && std::all_of(result_null_map.begin(),
result_null_map.end(),
+ [](uint8_t is_null) { return
is_null != 0; })) {
+ auto col_to = ColumnVector<PType>::create();
+ col_to->resize(input_rows_count);
+ block.replace_by_position(
+ result,
+ ColumnNullable::create(std::move(col_to),
std::move(result_null_map_column)));
+ return Status::OK();
+ }
+
// Extract nested columns from const(nullable) wrappers
argument_columns[0] = col_const[0] ? static_cast<const ColumnConst&>(
*block.get_by_position(arguments[0]).column)
diff --git a/be/test/exprs/function/function_time_test.cpp
b/be/test/exprs/function/function_time_test.cpp
index 738129640a9..afb622c459d 100644
--- a/be/test/exprs/function/function_time_test.cpp
+++ b/be/test/exprs/function/function_time_test.cpp
@@ -461,6 +461,21 @@ TEST(VTimestampFunctionsTest, date_test) {
static_cast<void>(check_function<DataTypeDateV2, true>(func_name,
input_types, data_set));
}
+TEST(VTimestampFunctionsTest, date_floor_null_period_validation_test) {
+ const InputTypeSet input_types = {Nullable {PrimitiveType::TYPE_DATEV2},
+ Consted {PrimitiveType::TYPE_INT}};
+
+ // NULL input rows must be returned as NULL before validating a constant
period.
+ const DataSet null_date_data_set = {{{Null(), int32_t {0}}, Null()}};
+ static_cast<void>(
+ check_function<DataTypeDateV2, true>("month_floor", input_types,
null_date_data_set));
+
+ // A non-NULL input row must still reject an invalid constant period.
+ const DataSet non_null_date_data_set = {{{std::string("2023-01-01"),
int32_t {0}}, Null()}};
+ static_cast<void>(check_function<DataTypeDateV2, true>("month_floor",
input_types,
+
non_null_date_data_set, -1, -1, true));
+}
+
TEST(VTimestampFunctionsTest, week_test) {
std::string func_name = "week";
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]