Support binary mathematical operators work with NULL literals#2610
Merged
alamb merged 2 commits intoapache:masterfrom May 26, 2022
Merged
Support binary mathematical operators work with NULL literals#2610alamb merged 2 commits intoapache:masterfrom
NULL literals#2610alamb merged 2 commits intoapache:masterfrom
Conversation
NULLNULL
alamb
approved these changes
May 24, 2022
| } | ||
|
|
||
| /// 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 { |
| &ll, | ||
| $RIGHT.try_into()?, | ||
| )?)) | ||
| match $RIGHT { |
Contributor
There was a problem hiding this comment.
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
?
jackwener
reviewed
May 26, 2022
| @@ -282,7 +282,7 @@ fn mathematics_numerical_coercion( | |||
| use arrow::datatypes::DataType::*; | |||
|
|
|||
| // error on any non-numeric type | |||
Member
There was a problem hiding this comment.
Suggested change
| // error on any non-numeric type | |
| // error on any not numeric/null type |
Contributor
Author
|
cc @alamb PTAL, thank you |
NULLNULL literals
Contributor
|
Thanks @WinkerDu and @jackwener -- 🤗 |
ovr
pushed a commit
to cube-js/arrow-datafusion
that referenced
this pull request
Aug 15, 2022
…he#2610) * binary mathematical operator with NULL * code clean
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

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.