mrhhsg opened a new pull request, #67184:
URL: https://github.com/apache/doris/pull/67184
### What problem does this PR solve?
Issue Number: None
Related PR: None
Problem Summary:
`days_add`, `days_sub`, `weeks_add`, and `weeks_sub` on DATEV2 and DATETIMEV2
currently use the generic `DateV2Value::date_add_interval` path for every
row.
That path constructs a `TimeInterval`, converts the date through second-level
arithmetic, and rebuilds date and time fields even though day and week
intervals
only move the date part.
This PR adds an inline `DateV2Value::date_add_days` fast path. Dates in the
existing 1900-2039 day-offset dictionary use direct day-number and
reverse-date
lookups; inputs or results outside that dictionary retain the generic
implementation. DATETIMEV2 keeps its time fields unchanged, and result range
checks preserve the existing out-of-range behavior.
An author microbenchmark measured approximately 8.8 ns to 2.6 ns per row for
clustered dates and 8.8 ns to 3.5 ns for dates spread across 1950-2030.
Differential coverage compares the new helper with the generic implementation
across the supported date domain. Focused function tests cover leap years,
boundaries, large deltas, DATEV2, DATETIMEV2, add/subtract paths, and
out-of-range results.
### Release note
None
### Check List (For Author)
- Test
- [x] Unit Test
- [ ] Regression test
- [ ] Manual test
- [ ] No need to test or manual test
- Behavior changed:
- [x] No
- [ ] Yes
- Does this need documentation?
- [x] No
- [ ] Yes
Validation:
- `./run-be-ut.sh --run
--filter='VDateTimeValueTest.date_add_days_matches_date_add_interval:VTimestampFunctionsTest.days_add_v2_test:VTimestampFunctionsTest.days_add_v2_boundary_test:VTimestampFunctionsTest.days_sub_v2_test:VTimestampFunctionsTest.weeks_add_v2_test:VTimestampFunctionsTest.weeks_add_v2_boundary_test:VTimestampFunctionsTest.weeks_sub_v2_test'
-j16` — 7 tests passed under ASAN_UT.
- `build-support/check-build-hygiene.sh` — passed.
- `build-support/clang-format.sh`, `build-support/check-format.sh`, and `git
diff --check origin/master...HEAD` — passed.
- `build-support/run-clang-tidy.sh --base origin/master --build-dir
be/ut_build_ASAN` — no diagnostics on changed ranges after the targeted
suppression for GTest macro expansion; the overall command remains non-zero
because of pre-existing diagnostics outside the diff and toolchain
header-resolution errors such as missing `stddef.h`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]