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

feat(expr): convert timestamp with time zone from/to unix epoch seconds #5910

Merged
merged 6 commits into from
Oct 18, 2022

Conversation

xiangjinwu
Copy link
Contributor

@xiangjinwu xiangjinwu commented Oct 18, 2022

I hereby agree to the terms of the Singularity Data, Inc. Contributor License Agreement.

What's changed and what's your intention?

Support the following exprs:

  • to_timestamp(seconds: double precision) -> timestamp with time zone
  • extract(epoch from timestamp with time zone) -> seconds: decimal

This also updates the parser to allow arbitrary string as extract units, to align with PostgreSQL.

Checklist

  • I have written necessary rustdoc comments
  • I have added necessary unit tests and integration tests
  • All checks passed in ./risedev check (or alias, ./risedev c)

Documentation

Types of user-facing changes

  • SQL commands, functions, and operators

Release note

  • Allows converting timestamp with time zone from seconds since unix epoch via to_timestamp.
  • Allows converting timestamp with time zone to seconds since unix epoch via extract(epoch from).

Refer to a related PR or issue link (optional)

#5805 (comment)
#5826
#5588
Fixes #5859

@xiangjinwu xiangjinwu marked this pull request as ready for review October 18, 2022 14:38
@xiangjinwu
Copy link
Contributor Author

ci error seems irrelevant: #5911

@codecov
Copy link

codecov bot commented Oct 18, 2022

Codecov Report

Merging #5910 (91914e9) into main (6d8c3c5) will increase coverage by 0.03%.
The diff coverage is 61.27%.

@@            Coverage Diff             @@
##             main    #5910      +/-   ##
==========================================
+ Coverage   74.85%   74.89%   +0.03%     
==========================================
  Files         922      924       +2     
  Lines      146824   147014     +190     
==========================================
+ Hits       109911   110103     +192     
+ Misses      36913    36911       -2     
Flag Coverage Δ
rust 74.89% <61.27%> (+0.03%) ⬆️

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

Impacted Files Coverage Δ
src/common/src/types/interval.rs 83.79% <0.00%> (-3.34%) ⬇️
src/common/src/types/mod.rs 64.58% <0.00%> (ø)
src/common/src/util/mod.rs 0.00% <ø> (ø)
src/common/src/util/value_encoding/mod.rs 46.66% <0.00%> (+0.28%) ⬆️
src/expr/src/expr/expr_binary_nonnull.rs 77.66% <0.00%> (-1.59%) ⬇️
src/expr/src/expr/expr_unary.rs 62.42% <0.00%> (-0.94%) ⬇️
src/expr/src/vector_op/cast.rs 84.29% <0.00%> (-2.20%) ⬇️
src/expr/src/vector_op/extract.rs 85.00% <0.00%> (-13.08%) ⬇️
src/expr/src/vector_op/timestampz.rs 0.00% <0.00%> (ø)
src/frontend/src/handler/util.rs 77.35% <0.00%> (-0.99%) ⬇️
... and 51 more

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

Copy link
Contributor

@nanderstabel nanderstabel left a comment

Choose a reason for hiding this comment

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

Looks great!

@mergify mergify bot merged commit 938f427 into main Oct 18, 2022
@mergify mergify bot deleted the XJ-feat-tstz-seconds branch October 18, 2022 18:48
@xiangjinwu xiangjinwu added the user-facing-changes Contains changes that are visible to users label Oct 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/feature user-facing-changes Contains changes that are visible to users
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bug: Parser doesn't support extract(DOW)
2 participants