jacktengg opened a new pull request, #70003:
URL: https://github.com/apache/doris/pull/70003
### What problem does this PR solve?
Issue Number: None
Related PR: None
Problem Summary:
TIMESTAMPTZ day arithmetic currently changes UTC fields, so adding one day
across a DST transition adds exactly 24 hours and shifts the local clock. In an
America/New_York session, `days_add(CAST('2024-03-09 12:00:00-05:00' AS
TIMESTAMPTZ(6)), 1)` produces 13:00 the following day instead of 12:00.
Apply DAY intervals to the session-local date in BE and FE constant folding,
then resolve the result back to UTC. Preserve fractional seconds, the input
offset for repeated local times, existing cctz gap resolution, and date-range
errors. This covers days_add/days_sub and their SQL aliases; hours_add remains
elapsed-time arithmetic.
Local-day arithmetic can reverse UTC ordering at a fall-back and is not
always invertible. Restrict its monotonicity declaration in variable-offset
zones and prevent comparison rearrangement from replacing a DAY predicate with
an invalid inverse operation. For example, moving the interval in `days_add(ts,
1) < '2024-11-04 01:30:00-05:00'` can incorrectly include the first 01:50 from
the preceding fall-back day.
### Release note
TIMESTAMPTZ day addition and subtraction now preserve session-local calendar
time across daylight-saving transitions. One day may represent 23 or 25 elapsed
hours; explicitly adding 24 hours retains elapsed-time semantics.
### Check List (For Author)
- Test
- [x] Regression test: test_timestamptz_days_add_dst,
test_timestamptz_dst_fold, test_timestamptz_dst_gap,
test_timestamptz_utc_functions
- [x] Unit Test: 19 FE tests (TimestampTzLiteralTest and
SimplifyArithmeticComparisonRuleTest); 10 BE tests (TimeStampTzValueTest and
selected VTimestampFunctionsTest cases)
- [x] Manual test: New York spring transition returns local 12:00 and
82800 seconds; explicit 24 hours returns 13:00
- Validation: ASAN BE build, FE build with Checkstyle, clang-format 16,
build hygiene, and clang-tidy on modified C++ files
- Regression expected results generated by run-regression-test.sh; FE
folding and BE results compared
- Behavior changed:
- [x] Yes. TIMESTAMPTZ DAY intervals use the session-local calendar;
DST-sensitive monotonicity and comparison rearrangement are restricted.
- Does this need documentation?
- [x] No. Existing date arithmetic bug fix; release note included.
### 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]