-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Support binary mathematical operators work with NULL literals
#2610
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
Conversation
NULLNULL
alamb
left a comment
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.
Love it -- thank you @WinkerDu
Keep the code train moving 🚋
| } | ||
|
|
||
| /// Determine if at least of one of lhs and rhs is numeric, and the other must be NULL or numeric | ||
| fn both_numeric_or_null_and_numeric(lhs_type: &DataType, rhs_type: &DataType) -> bool { |
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.
👍
| &ll, | ||
| $RIGHT.try_into()?, | ||
| )?)) | ||
| match $RIGHT { |
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 wonder if you could use ScalarValue::is_null() here rather than having to expand the macros out more
https://github.com/apache/arrow-datafusion/blob/master/datafusion/common/src/scalar.rs#L627
?
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.
nice catch!
| ) -> Option<DataType> { | ||
| use arrow::datatypes::DataType::*; | ||
|
|
||
| // error on any non-numeric type |
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.
| // error on any non-numeric type | |
| // error on any not numeric/null type |
jackwener
left a comment
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.
LGTM after fix review.
Thanks @WinkerDu ❤️.
|
cc @alamb PTAL, thank you |
alamb
left a comment
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.
NULLNULL literals
|
Thanks @WinkerDu and @jackwener -- 🤗 |
…he#2610) * binary mathematical operator with NULL * code clean

Which issue does this PR close?
Closes #2609 .
Rationale for this change
There is bug when binary mathematical operators
+,-,*,/,%work with literalNULLTo reproduce
Postgres works like
What changes are included in this PR?
mathematics_numerical_coercioninbinary_rule.rs, make it work well on condition that at most one side of lhs or rhs isNULLcompute_op_scalarmacro inbinary.rsto produceNULLarray when scalar value isNULLAre there any user-facing changes?
No.