branch-4.1: [fix](be) Reject oversized Unix timestamps before year narrowing #68115 - #68364
Merged
Merged
Conversation
) ### What problem does this PR solve? Issue Number: N/A Problem Summary: `from_unixtime` and `from_second` / `from_millisecond` / `from_microsecond` validate the date after converting an integer Unix timestamp. The conversion passes the civil year to a `uint16_t` setter first, so some out-of-range years wrap into the valid range and escape validation. For example, in UTC, `2068116364800` seconds is year 67506, which narrows to 1970. A BIGINT column containing this value can therefore return `1970-01-01 00:00:00` instead of the documented out-of-range error. Check the timestamp before conversion using a shared upper bound of the last second of UTC year 9999 plus one day for time zone offsets. Keep the existing post-conversion date check for the exact local boundary and the existing function-specific errors. The seconds/milliseconds/microseconds functions reuse their existing division; no additional time-zone conversion or per-row allocation is introduced. The regression covers both year-wrap values, BIGINT_MAX, formatted and unformatted `from_unixtime`, all three timestamp units, literals and table columns, constant folding enabled/disabled, NULL, and legal/illegal boundaries in UTC, +14:00 and -12:00. The legacy `from_unixtime` path already has a smaller upper bound. Decimal overloads have at most 12 integer digits and cannot reach these year-wrap inputs. ### Release note Reject oversized integer Unix timestamps that previously wrapped into apparently valid dates in `from_unixtime`, `from_second`, `from_millisecond`, and `from_microsecond`. ### Check List (For Author) - Test: - [x] Regression test: `./run-regression-test.sh --run -d datatype_p0/date -s test_unix_timestamp_range,test_from_unixtime` (2 suites passed). Expected output generated with `-genOut` and then verified without generation. - [x] Unit Test: `./run-be-ut.sh -j 48 --run --filter='VTimestampFunctionsTest.*'` (82 passed, ASAN). - Behavior changed: - [x] Yes. Invalid oversized timestamps now return the existing out-of-range error; valid time-zone boundaries remain supported. - Does this need documentation? - [x] No. This restores the documented out-of-range error behavior. Build: `./build.sh --be --fe -j 48` passed (ASAN). Validation used the merge result with master `c4dee4bd5e8`; `git merge-tree` confirms it is byte-for-byte identical to the tested tree. Validation note: clang-format and build hygiene checks pass. clang-tidy is blocked by the pre-existing unmatched `NOLINTEND` in `be/src/core/types.h:576`; this unrelated file is unchanged. ### Check List (For Reviewer who merge this PR) - [ ] Confirm the release note - [ ] Confirm test cases - [ ] Confirm document - [ ] Add branch pick label
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
|
yiguolei
approved these changes
Sep 23, 2026
Contributor
Author
|
PR approved by anyone and no changes requested. |
Contributor
Author
|
PR approved by at least one committer and no changes requested. |
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 #68115