This is an automated email from the ASF dual-hosted git repository.
Mryange pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push:
new 846d9b2ebfc [fix](be) Preserve NULL propagation in date floor
functions (#67951)
846d9b2ebfc is described below
commit 846d9b2ebfc595ddfd77579447db16a674c901f7
Author: Mryange <[email protected]>
AuthorDate: Tue Sep 15 12:45:26 2026 +0800
[fix](be) Preserve NULL propagation in date floor functions (#67951)
`month_floor` and `week_floor` validated a constant non-positive period
before processing the merged NULL map. As a result, rows with a NULL
date and period `0` could error instead of returning NULL. Return an
all-NULL result block before the constant-period fast path while
preserving validation for non-NULL rows.
### Release note
None
### Check List (For Author)
- Test <!-- At least one of them must be included. -->
- [ ] Regression test
- [ ] Unit Test
- [ ] Manual test (add detailed scripts or steps below)
- [ ] No need to test or manual test. Explain why:
- [ ] This is a refactor/code format and no logic has been changed.
- [ ] Previous test can cover this change.
- [ ] No code files have been changed.
- [ ] Other reason <!-- Add your reason? -->
- Behavior changed:
- [ ] No.
- [ ] Yes. <!-- Explain the behavior change -->
- Does this need documentation?
- [ ] No.
- [ ] Yes. <!-- Add document PR link here. eg:
https://github.com/apache/doris-website/pull/1214 -->
### Check List (For Reviewer who merge this PR)
- [ ] Confirm the release note
- [ ] Confirm test cases
- [ ] Confirm document
- [ ] Add branch pick label <!-- Add branch pick label that this PR
should merge into -->
---
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 f4ac7c3e037..7daf7c412e5 100644
--- a/be/src/exprs/function/function_datetime_floor_ceil.cpp
+++ b/be/src/exprs/function/function_datetime_floor_ceil.cpp
@@ -175,6 +175,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 3f3b9b83c40..6104ebd9954 100644
--- a/be/test/exprs/function/function_time_test.cpp
+++ b/be/test/exprs/function/function_time_test.cpp
@@ -453,6 +453,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]