Numeric, String, Boolean comparisons with literal NULL#2481
Numeric, String, Boolean comparisons with literal NULL#2481yjshen merged 1 commit intoapache:masterfrom
NULL#2481Conversation
|
cc @alamb @andygrove @yjshen @xudong963 |
| stringify!($OP), | ||
| ))) | ||
| // when the $RIGHT is a NULL, generate a NULL array of $OP_TYPE | ||
| Ok(Arc::new(new_null_array($OP_TYPE, $LEFT.len()))) |
There was a problem hiding this comment.
- I think we should respect
SortOptionshere for ScalaValue. - Question: how about the
NULL != columncase? Do we have an expression normalizer that asserts Nulls often coming as the right-hand operand for a binary comparison?
There was a problem hiding this comment.
@yjshen what do you mean SortOptions? I don't think these expressions are used directly in ORDER BY clauses -- they are used instead for expressions like a < b
Adding some more tests in sql/expr.rs for NULL < column and NULL > column sounds like a good idea.
There was a problem hiding this comment.
After checking Postgres and MySQL, I found I'm wrong on the expected behavior while comparing columns with NULL using < > ..., they will return NULL in all cases. I was expecting to apply null first or null last while comparing column with NULL, so always true or always false at the first time.
There was a problem hiding this comment.
I will spend some time writing the NULL != column
| stringify!($OP), | ||
| ))) | ||
| // when the $RIGHT is a NULL, generate a NULL array of $OP_TYPE | ||
| Ok(Arc::new(new_null_array($OP_TYPE, $LEFT.len()))) |
There was a problem hiding this comment.
@yjshen what do you mean SortOptions? I don't think these expressions are used directly in ORDER BY clauses -- they are used instead for expressions like a < b
Adding some more tests in sql/expr.rs for NULL < column and NULL > column sounds like a good idea.
yjshen
left a comment
There was a problem hiding this comment.
Thanks @WinkerDu. I think the current behavior that always yields null while comparing with null is consistent with other systems, so no more efforts are required on this.
It would be nice to guarantee expression normalization exists and always have scalar value as the right operand after normalization. I think this goes beyond the scope of this PR and we could do it as follow-ups.
Thanks for your perseverance and nice work!
| stringify!($OP), | ||
| ))) | ||
| // when the $RIGHT is a NULL, generate a NULL array of $OP_TYPE | ||
| Ok(Arc::new(new_null_array($OP_TYPE, $LEFT.len()))) |
There was a problem hiding this comment.
I will spend some time writing the NULL != column
Which issue does this PR close?
Closes #1179 and #2482 .
Rationale for this change
This pr aims to solve Numeric, String, Boolean comparisons (Binary Expressions) with literal
NULLFor now, DF would fail when running the following SQLs:
What changes are included in this PR?
null_coerciontocomparison_eq_coercionandcomparison_order_coercionNULLscalar value comparing with array, likebinary_array_op_dyn_scalarAre there any user-facing changes?
No.