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

bug(expr): date_trunc handles ambiguity during DST backward incorrectly #12072

Closed
xiangjinwu opened this issue Sep 5, 2023 · 0 comments · Fixed by #13201
Closed

bug(expr): date_trunc handles ambiguity during DST backward incorrectly #12072

xiangjinwu opened this issue Sep 5, 2023 · 0 comments · Fixed by #13201
Assignees
Labels
type/bug Something isn't working
Milestone

Comments

@xiangjinwu
Copy link
Contributor

xiangjinwu commented Sep 5, 2023

Describe the bug

Our implementation of date_trunc on timestamptz includes a rewrite: the time is converted to naive local time first, truncated, and then converted back. This introduces unnecessary ambiguity that is impossible to resolve correctly: the first conversion may convert different timestamptz to the same naive local time, which cannot be convert back to different values in the last step.

Error message/log

Silently produce a wrong value without errors. See repro below:

To Reproduce

RisingWave:

dev=> select extract(epoch from date_trunc('hour', '2023-11-05 01:40:00-07:00'::timestamptz, 'US/Pacific'));
      extract      
-------------------
 1699174800.000000
(1 row)

dev=> select extract(epoch from date_trunc('hour', '2023-11-05 01:40:00-08:00'::timestamptz, 'US/Pacific'));
      extract      
-------------------
 1699174800.000000
(1 row)

Expected behavior

PostgreSQL:

test=# select extract(epoch from date_trunc('hour', '2023-11-05 01:40:00-07:00'::timestamptz, 'US/Pacific'));
      extract      
-------------------
 1699171200.000000
(1 row)

test=# select extract(epoch from date_trunc('hour', '2023-11-05 01:40:00-08:00'::timestamptz, 'US/Pacific'));
      extract      
-------------------
 1699174800.000000
(1 row)

How did you deploy RisingWave?

No response

The version of RisingWave

No response

Additional context

Inspired by #12062 when reasoning whether date_trunc is always monotonic in all cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant