-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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: negation of Intervals
#6312
Conversation
query ? | ||
select -interval '5' - '1' - '2' year; | ||
---- | ||
0 years -24 mons 0 days 0 hours 0 mins 0.000000000 secs |
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.
why it is -24 mons, not -2 years? 🤔
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 don't clearly know why years always translate to months (See: Example) (maybe because the output function use IntervalYearMonth::to_months()
. But, I think it is not the actual problem of this PR.
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 don't clearly know why years always translate to months (See: Example) (maybe because the output function use
IntervalYearMonth::to_months()
. But, I think it is not the actual problem of this PR.
right, I'll investigate if we need a follow up on this
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 extract( year from interval '5' year);
This works in PG and returns 5 years
But fails in DF, I'll create another ticket on this.
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 think it is related to the fact that interval gets parsed to the same IntervalMonthDayNano all the time -- which was changed in #5806
I think to handle it properly we need to have cast support between the different interval types, maybe 🤔
use datafusion_common::{cast::as_primitive_array, Result}; | ||
use paste::paste; | ||
|
||
macro_rules! test_array_negative_op { |
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.
thank you for adding this coverage of regular negate
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.
* feat: negation of Intervals * fix: clippy
Which issue does this PR close?
Closes #6311
Rationale for this change
What changes are included in this PR?
Are these changes tested?
Yes
Are there any user-facing changes?
Yes