[fix](nereids) Fix DST spring-forward gap handling in datetime literal timezone conversion#62814
Draft
Mryange wants to merge 1 commit intoapache:masterfrom
Draft
[fix](nereids) Fix DST spring-forward gap handling in datetime literal timezone conversion#62814Mryange wants to merge 1 commit intoapache:masterfrom
Mryange wants to merge 1 commit intoapache:masterfrom
Conversation
Contributor
|
Thank you for your contribution to Apache Doris. Please clearly describe your PR:
|
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.
What problem does this PR solve?
Issue Number: N/A
Problem Summary:
When inserting a
TIMESTAMPTZvalue whose civil time falls in a DST spring-forward gap(e.g.
'2024-03-10 02:30:00 America/New_York'— a time that does not exist becauseclocks jump from 02:00 EST to 03:00 EDT), the two FE literal-parsing paths produced
different UTC instants:
'... America/New_York')02:30:00 NY06:30 UTCSET time_zone='America/New_York')02:30:0007:30 UTCThe correct answer is
07:30 UTC: Java'sZonedDateTime.of()snaps the non-existentgap time to 03:30 EDT (= 07:30 UTC), but the old code then queried
zoneId.getRules().getOffset(thatTime)which returned the post-snap EDT offset(
-04:00) instead of the pre-gap EST offset (-05:00). Applying this wrong offsetto the original pre-snap civil time
02:30yielded the incorrect06:30 UTC.Root cause
Both
parseDateTimeLiteral()andinit()inDateTimeLiteral.javaused the pattern:Fix
Replace the offset-delta arithmetic with a direct zone projection of the correctly
snapped absolute instant:
This applies to both the session-timezone path (for
DateTimeLiteral) and theUTC-storage path (for
TimestampTzLiteral).Changes
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/literal/DateTimeLiteral.java:Fix
parseDateTimeLiteral()andinit()to convert viaInstant.atZone()insteadof an offset delta.
fe/fe-core/src/test/java/org/apache/doris/nereids/trees/expressions/literal/TimestampTzLiteralTest.java:Add
testSpringForwardGapConsistency()unit test.regression-test/suites/datatype_p0/timestamptz/test_timestamptz_dst_gap.groovy:Add regression test covering both named-TZ and implicit session-TZ paths for a
spring-forward gap time, asserting they produce the same UTC instant.
Release note
None
Check List (For Author)
Test
Behavior changed:
Does this need documentation?
Check List (For Reviewer who merge this PR)