branch-4.1: [improvement](function) Add dictionary fast path for day and week arithmetic #67184 - #67233
Open
github-actions[bot] wants to merge 1 commit into
Open
branch-4.1: [improvement](function) Add dictionary fast path for day and week arithmetic #67184#67233github-actions[bot] wants to merge 1 commit into
github-actions[bot] wants to merge 1 commit into
Conversation
…thmetic (#67184) `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`.
Contributor
|
Thank you for your contribution to Apache Doris. Please clearly describe your PR:
|
Contributor
|
run buildall |
Contributor
BE UT Coverage ReportIncrement line coverage Increment coverage report
|
Contributor
BE Regression && UT Coverage ReportIncrement line coverage Increment coverage report
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Cherry-picked from #67184