Skip to content
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): date_trunc and +/- on timestamptz during DST jump-back #13201

Merged
merged 1 commit into from
Nov 2, 2023

Conversation

xiangjinwu
Copy link
Contributor

@xiangjinwu xiangjinwu commented Nov 1, 2023

I hereby agree to the terms of the RisingWave Labs, Inc. Contributor License Agreement.

What's changed and what's your intention?

For context, 2023-11-05 01:59:59-07:00 is followed by 2023-11-05 01:00:00-08:00 in US/Pacific.

There are two 2023-11-05 01:40:00 in local time, corresponding to UTC time 2023-11-05T08:40:00Z (1699173600s since the unix epoch) and 2023-11-05T09:40:00Z (1699177200s since the unix epoch).

And also two 2023-11-05 01:00:00 in local time, corresponding to UTC time 2023-11-05T08:00:00Z (1699171200s since the unix epoch) and 2023-11-05T09:00:00Z (1699174800s since the unix epoch).

Fixes #12072

In short:

  • date_trunc to hour of 2023-11-05 01:40:00 in Pacific Daylight Time (-07:00) shall return 2023-11-05 01:00:00 in Pacific Daylight Time, rather than Pacific Standard Time (-08:00).
    • date_trunc to microseconds of 2023-11-05 08:40:00Z and 2023-11-05 09:35:00Z under US/Pacific shall return them unchanged, rather than 2023-11-05 09:40:00Z and 2023-11-05 09:35:00Z (non-monotonic).
  • Under set timezone = 'US/Pacific', '2023-11-05 01:40:00-07:00'::timestamptz + interval '5' minute shall return 2023-11-05 01:45:00-07:00 rather than 2023-11-05 01:45:00-08:00 (which is 65 minutes later).

Checklist

  • I have written necessary rustdoc comments
  • I have added necessary unit tests and integration tests
  • I have added fuzzing tests or opened an issue to track them. (Optional, recommended for new SQL features Sqlsmith: Sql feature generation #7934).
  • My PR contains breaking changes. (If it deprecates some features, please create a tracking issue to remove them in the future).
  • All checks passed in ./risedev check (or alias, ./risedev c)
  • My PR changes performance-critical code. (Please run macro/micro-benchmarks and show the results.)
  • My PR contains critical fixes that are necessary to be merged into the latest release. (Please check out the details)

Documentation

  • My PR needs documentation updates. (Please use the Release note section below to summarize the impact on users)

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.

@github-actions github-actions bot added the type/fix Bug fix label Nov 1, 2023
Copy link

codecov bot commented Nov 1, 2023

Codecov Report

Merging #13201 (88be4d2) into main (6bd797e) will decrease coverage by 0.03%.
The diff coverage is 10.63%.

@@            Coverage Diff             @@
##             main   #13201      +/-   ##
==========================================
- Coverage   68.07%   68.04%   -0.03%     
==========================================
  Files        1512     1512              
  Lines      256245   256258      +13     
==========================================
- Hits       174441   174380      -61     
- Misses      81804    81878      +74     
Flag Coverage Δ
rust 68.04% <10.63%> (-0.03%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
src/expr/impl/src/scalar/timestamptz.rs 80.34% <50.00%> (-1.72%) ⬇️
src/expr/impl/src/scalar/date_trunc.rs 1.40% <0.00%> (-0.16%) ⬇️

... and 10 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Copy link
Contributor

@wangrunji0408 wangrunji0408 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. The human time system is too complicated. 🥵

@wangrunji0408 wangrunji0408 added this pull request to the merge queue Nov 2, 2023
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Nov 2, 2023
@xiangjinwu xiangjinwu added this pull request to the merge queue Nov 2, 2023
Merged via the queue into main with commit 2ce7c9f Nov 2, 2023
12 of 13 checks passed
@xiangjinwu xiangjinwu deleted the fix-12072-expr-date-trunc-timestamptz-dst branch November 2, 2023 11:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/fix Bug fix
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bug(expr): date_trunc handles ambiguity during DST backward incorrectly
2 participants