-
Notifications
You must be signed in to change notification settings - Fork 593
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(expr): handle invalid local time during daylight saving forward #15670
Conversation
Signed-off-by: Runji Wang <[email protected]>
Signed-off-by: Runji Wang <[email protected]>
// * use UTC offset after the transition | ||
let instant_local = match input.0.and_local_timezone(time_zone) { | ||
LocalResult::Single(t) => t, | ||
LocalResult::None => (input.0 + chrono::Duration::hours(1)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI although the difference of 1-hour is very common, it is not always the case. As mentioned in issue_12072.slt.part
, it could be half hour. Additionally, there may be one-off changes other than regular daylight saving, for example Singapore jumped from 1981-12-31 23:29:59
to 1982-01-01 00:00:00
. ('1981-12-31 23:40'::timestamp at time zone 'Asia/Singapore'
in PostgreSQL corresponds to 1981-12-31T16:10:00Z
) The Singapore example is also half hour but such one-off change may be more arbitrary.
A real fix is to update the binary search logic inside chrono
locating time zone offsets. If a naive time does not match any entry, it shall return its preceding and following entry rather than None
. So that we can pick the preceding entry to match PostgreSQL.
A quick hack may be to minus 3 hours in naive time first, do the timezone conversion, and add 3 hours back in the UTC timeline. This assumes jump forwards are less than 3 hours (IIRC there was 2-hour change) and there is a single change within this 3-hour window.
To clarify my word usage in this comment: Asia/Singapore
is a timezone, while UTC+07:30
and UTC+08:00
are two offsets used by this timezone.
Signed-off-by: Runji Wang <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we include the Singapore test case as well? Just as a reminder there are arbitrary one-off changes in addition to regular daylight saving.
Test failed in this case. 🥵
Observations:
I decide to add the test case but just ignore it for now. After all it is very unlikely to encounter this problem in production. |
Signed-off-by: Runji Wang <[email protected]>
I tried |
…15670) Signed-off-by: Runji Wang <[email protected]>
I hereby agree to the terms of the RisingWave Labs, Inc. Contributor License Agreement.
What's changed and what's your intention?
Recently US timezone started Daylight Saving Time since 2024-03-10 02:00. RisingWave could not correctly convert timestamps to local time during 2024-03-10 02:00-03:00.
This PR fixes this error and makes its behavior consistent with postgres.
Checklist
./risedev check
(or alias,./risedev c
)Documentation
Release note
If this PR includes changes that directly affect users or other significant modifications relevant to the community, kindly draft a release note to provide a concise summary of these changes. Please prioritize highlighting the impact these changes will have on users.