HappenLee opened a new pull request, #68115: URL: https://github.com/apache/doris/pull/68115
### What problem does this PR solve? Issue Number: N/A Related PR: https://github.com/facebookincubator/velox/pull/18966 (range-check audit that exposed this separate Doris issue) 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 -- 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]
