Skip to content

Conversation

@wangrunji0408
Copy link
Contributor

@wangrunji0408 wangrunji0408 commented Nov 15, 2022

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

What's changed and what's your intention?

This PR adds support for date_trunc function.

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

If your pull request contains user-facing changes, please specify the types of the changes, and create a release note. Otherwise, please feel free to remove this section.

Types of user-facing changes

Please keep the types that apply to your changes, and remove those that do not apply.

  • SQL commands, functions, and operators

Release note

Please create a release note for your changes. In the release note, focus on the impact on users, and mention the environment or conditions where the impact may occur.

As documented in postgres: https://www.postgresql.org/docs/current/functions-datetime.html#FUNCTIONS-DATETIME-TRUNC.

Except that timezone must be specified if source is a timestamp with time zone:

date_trunc(field, TIMESTAMPZ, time_zone) // ok
date_trunc(field, TIMESTAMPZ) // not supported for now

Reason: #6365 (comment).

Refer to a related PR or issue link (optional)

resolve #6301

@wangrunji0408 wangrunji0408 added the user-facing-changes Contains changes that are visible to users label Nov 15, 2022
@github-actions github-actions bot added the type/feature Type: New feature. label Nov 15, 2022
Copy link
Contributor

@BowenXiao1999 BowenXiao1999 left a comment

Choose a reason for hiding this comment

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

LSTM!

Copy link
Contributor

@xiangjinwu xiangjinwu left a comment

Choose a reason for hiding this comment

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

rest lgtm

@codecov
Copy link

codecov bot commented Nov 15, 2022

Codecov Report

Merging #6365 (e7c7826) into main (ddae931) will decrease coverage by 0.21%.
The diff coverage is 26.78%.

@@            Coverage Diff             @@
##             main    #6365      +/-   ##
==========================================
- Coverage   74.28%   74.06%   -0.22%     
==========================================
  Files         960      966       +6     
  Lines      156525   157164     +639     
==========================================
+ Hits       116277   116406     +129     
- Misses      40248    40758     +510     
Flag Coverage Δ
rust 74.06% <26.78%> (-0.22%) ⬇️

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

Impacted Files Coverage Δ
src/common/src/types/chrono_wrapper.rs 46.66% <0.00%> (-15.91%) ⬇️
src/common/src/types/interval.rs 72.10% <0.00%> (-7.47%) ⬇️
src/common/src/types/mod.rs 72.40% <0.00%> (ø)
src/expr/src/expr/build_expr_from_prost.rs 53.76% <0.00%> (-1.91%) ⬇️
src/expr/src/expr/expr_binary_nonnull.rs 62.80% <0.00%> (-8.89%) ⬇️
src/expr/src/expr/mod.rs 47.91% <0.00%> (-1.02%) ⬇️
src/expr/src/vector_op/date_trunc.rs 0.00% <0.00%> (ø)
src/source/src/connector_source.rs 82.35% <ø> (ø)
src/source/src/parser/pb_parser/schema_resolver.rs 0.00% <0.00%> (ø)
src/source/src/parser/schema_registry/client.rs 0.00% <0.00%> (ø)
... and 34 more

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

Signed-off-by: Runji Wang <[email protected]>
@mergify mergify bot merged commit 07d0b34 into main Nov 16, 2022
@mergify mergify bot deleted the wrj/date-trunc branch November 16, 2022 04:13
xxchan pushed a commit that referenced this pull request Nov 19, 2022
* implement truncate for NaiveDateTime

Signed-off-by: Runji Wang <[email protected]>

* implement truncate for IntervalUnit

Signed-off-by: Runji Wang <[email protected]>

* implement `date_trunc` function

Signed-off-by: Runji Wang <[email protected]>

* fix truncate century and millennium for timestamp

Signed-off-by: Runji Wang <[email protected]>

* update date_trunc e2e test

Signed-off-by: Runji Wang <[email protected]>

* fix date_trunc for timestampz

Signed-off-by: Runji Wang <[email protected]>

* remove trailing '00:00:00'

Signed-off-by: Runji Wang <[email protected]>

* add placeholder for truncate_millis

Signed-off-by: Runji Wang <[email protected]>

* remove trailing '00:00:00'

Signed-off-by: Runji Wang <[email protected]>

* update dashboard proto

Signed-off-by: Runji Wang <[email protected]>

Signed-off-by: Runji Wang <[email protected]>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type/feature Type: New feature. user-facing-changes Contains changes that are visible to users

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: support date_trunc function

4 participants