-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Like, NotLike expressions work with literal NULL
#2627
Conversation
cc @andygrove @alamb @yjshen , Please have a review, thank you ❤️ |
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.
Looks good to me -- thank you @WinkerDu . I do wonder if this will work with NULL like <col>
but we can also fix that case in a follow on PR if you would prefer
datafusion/core/tests/sql/expr.rs
Outdated
#[tokio::test] | ||
async fn like_nlike_with_null_lt() { | ||
let ctx = SessionContext::new(); | ||
let sql = "SELECT column1 like NULL from (values('a'), ('b'), (NULL)) as t"; |
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.
Can you also add a test when the arguments are reversed? For example,:
let sql = "SELECT column1 like NULL from (values('a'), ('b'), (NULL)) as t"; | |
let sql = "SELECT column1 like NULL as col_null, NULL like column1 as null_col from (values('a'), ('b'), (NULL)) as t"; |
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.
@alamb Sounds reasonable, I've changed the ut, thank you
datafusion/core/tests/sql/expr.rs
Outdated
]; | ||
assert_batches_eq!(expected, &actual); | ||
|
||
let sql = "SELECT column1 not like NULL from (values('a'), ('b'), (NULL)) as t"; |
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.
let sql = "SELECT column1 not like NULL from (values('a'), ('b'), (NULL)) as t"; | |
let sql = "SELECT column1 not like NULL as col_null, NULL not like column as null_col from (values('a'), ('b'), (NULL)) as t"; |
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.
Done
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.
Thanks @WinkerDu
* like / not like work with NULL * add more ut
* like / not like work with NULL * add more ut
Which issue does this PR close?
Closes #2626 .
Rationale for this change
like
,not like
expressions doesn't work well with literalNULL
in DF.To Reproduce
Postgres works like
What changes are included in this PR?
null_coercion
tolike_coercion
compute_utf8_op_scalar
to produce null array when scalar valueNULL
inputs.Are there any user-facing changes?
No.
Does this PR break compatibility with Ballista?
No.