-
Notifications
You must be signed in to change notification settings - Fork 738
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(query): add date_diff function #16560
base: main
Are you sure you want to change the base?
Conversation
6e56eb2
to
3053fc0
Compare
optimized expr : 0_i64 | ||
output type : Int64 | ||
output domain : {0..=0} | ||
output : 0 |
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.
select date_diff(year, to_timestamp('2020-02-29 23:59:59.165575'), to_timestamp('2019-02-28 23:59:59.423179'))
expect -1
optimized expr : -3_i64 | ||
output type : Int64 | ||
output domain : {-3..=-3} | ||
output : -3 |
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.
I test in snowflake , select datediff(quarter, to_timestamp('2020-02-29 23:59:59.165575'), to_timestamp('2019-02-28 23:59:59.423179'))
expect -4
optimized expr : 1_i64 | ||
output type : Int64 | ||
output domain : {1..=1} | ||
output : 1 |
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.
select datediff(year, to_timestamp('2023-11-12 09:38:18.165575'), to_timestamp('2025-03-27 21:01:35.423179')) expect 2.
query T | ||
SELECT DATE_DIFF(YEAR, to_date('2012-02-29'), to_date('2013-02-28')) | ||
---- | ||
1 |
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.
consider test select DATE_DIFF(YEAR, TO_TIMESTAMP('2023-12-31 09:38:18.165575'), TO_TIMESTAMP('2024-01-01 21:01:35.423179')) the result should be 1.
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.
Also need to add some tests where the sign is negative
Sorry, I got you. But, what's the result of |
Oh, I just mean add a logic test case:
|
So what should I do is to fix it to be compatible with Snowflake and add more tests? |
Date diff about year just need to evaluate year sub. E.g. 2023-12-31 2024-01-01 just need to calc year sub. |
Ok, thank you.
TCeason ***@***.***> 于2024年10月8日周二 14:33写道:
… So what should I do is to fix it to be compatible with Snowflake and add
more tests?
Date diff about year just need to evaluate year sub. E.g.
2023-12-31 2024-01-01 just need to calc year sub.
—
Reply to this email directly, view it on GitHub
<#16560 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AL4OCSKJ7XXJNNZXDXK7I53Z2N4E7AVCNFSM6AAAAABPGYZISGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGOJYHE3DMNBQGI>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
06be419
to
df2d0fd
Compare
e0d0aaa
to
b9e9566
Compare
* support date and timestamp
b9e9566
to
29a36d8
Compare
I hereby agree to the terms of the CLA available at: https://docs.databend.com/dev/policies/cla/
Summary
related to #16534
Tests
Type of change
This change is