-
Notifications
You must be signed in to change notification settings - Fork 613
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
feat(expr): AT TIME ZONE
to convert between timestamp
and timestamptz
#5968
Merged
Merged
Changes from 6 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
8bad407
parse AT TIME ZONE
xiangjinwu 9a6331a
expr: AtTimeZone
xiangjinwu c309dd6
time zone parsing and conversion
xiangjinwu 0fde265
unit tests
xiangjinwu 510fc5d
e2e tests
xiangjinwu 635f470
comments
xiangjinwu 933a4c2
parse_time_zone -> lookup_time_zone
xiangjinwu 9024ca1
Merge branch 'main' into XJ-feat-tstz-at-time-zone
mergify[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# zone-independent instant -> local naive time | ||
query T | ||
select '2022-01-01 00:00:00Z'::timestamp with time zone AT TIME ZONE 'US/Pacific'; | ||
---- | ||
2021-12-31 16:00:00 | ||
|
||
# local naive time -> zone-independent instant | ||
query T | ||
select '2021-12-31 16:00:00'::timestamp AT TIME ZONE 'us/pacific'; | ||
---- | ||
2022-01-01 00:00:00+00:00 | ||
|
||
# Unlike PostgreSQL, we do not support invalid local time during daylight saving forward yet. | ||
statement error | ||
select '2022-03-13 02:00:00'::timestamp AT TIME ZONE 'us/pacific'; | ||
|
||
# Like PostgreSQL, ambiguous local time during daylight saving backward are interpreted as after the transition. | ||
query T | ||
select '2022-11-06 01:00:00'::timestamp AT TIME ZONE 'us/pacific'; | ||
---- | ||
2022-11-06 09:00:00+00:00 |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.
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.
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.
Seems we need to parse the timezone every row, not sure whether it can be heavy. 🤔
Some possible optimizations:
Constant
, use another optimized implementation like perf(expr): optimize to_char function with constant template #5130.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.
The parsing is a lookup of a static and perfect hash table (crate
phf
), where hash is done in a case-insensitive manner. So memoization / cache has no advantage here.It is still true that most cases this is a constant, though.
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.
Cool. Then there should be no problem.
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.
Updated the function name to
lookup_time_zone
.