-
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
Make scalar and array handling for array_has consistent #13683
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -352,6 +352,16 @@ AS VALUES | |
(arrow_cast(make_array([[1], [2]], [[2], [3]]), 'FixedSizeList(2, List(List(Int64)))'), arrow_cast(make_array([1], [2]), 'FixedSizeList(2, List(Int64))')) | ||
; | ||
|
||
statement ok | ||
CREATE TABLE array_has_table_null | ||
AS VALUES | ||
(make_array(1, 2), 1), | ||
(make_array(1, NULL), 1), | ||
(make_array(3, 4, 5), 2), | ||
(make_array(3, NULL, 5), 2), | ||
(make_array(NULL, NULL, NULL), 2) | ||
; | ||
|
||
statement ok | ||
CREATE TABLE array_distinct_table_1D | ||
AS VALUES | ||
|
@@ -5260,6 +5270,13 @@ select array_has([], null), | |
---- | ||
NULL NULL NULL | ||
|
||
# If lhs is has any Nulls, we return Null instead of false | ||
query BB | ||
select array_has([1, null, 2], 3), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure this is a correct behavior. Checking DuckDB
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm DuckDB is different then Spark and Postgres then
Was hoping to use this to implement There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Turns out the existing "correct" behavior for scalars doesn't match DuckDB either, which never returns null unless the whole array is null DuckDB
DF
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated to match DuckDB behavior and updated description |
||
array_has([null, null, null], 3); | ||
---- | ||
NULL NULL | ||
|
||
#TODO: array_has_all and array_has_any cannot handle NULL | ||
#query BBBB | ||
#select array_has_any([], null), | ||
|
@@ -5338,6 +5355,16 @@ from array_has_table_1D; | |
true true true | ||
false false false | ||
|
||
query B | ||
select array_has(column1, column2) | ||
from array_has_table_null; | ||
---- | ||
true | ||
true | ||
false | ||
NULL | ||
NULL | ||
|
||
query B | ||
select array_has(column1, column2) | ||
from fixed_size_array_has_table_1D; | ||
|
@@ -5541,9 +5568,9 @@ select array_has(column1, make_array(5, 6)), | |
from arrays; | ||
---- | ||
false false false true | ||
true false true false | ||
true false true NULL | ||
true false false true | ||
false true false false | ||
false true NULL false | ||
NULL NULL false false | ||
false false NULL false | ||
false false false NULL | ||
|
@@ -5556,9 +5583,9 @@ select array_has(arrow_cast(column1, 'LargeList(List(Int64))'), make_array(5, 6) | |
from arrays; | ||
---- | ||
false false false true | ||
true false true false | ||
true false true NULL | ||
true false false true | ||
false true false false | ||
false true NULL false | ||
NULL NULL false false | ||
false false NULL false | ||
false false false NULL | ||
|
@@ -5571,9 +5598,9 @@ select array_has(column1, make_array(5, 6)), | |
from fixed_size_arrays; | ||
---- | ||
false false false true | ||
true false true false | ||
true false true NULL | ||
true false false true | ||
false true false false | ||
false true NULL false | ||
NULL NULL false false | ||
false false NULL false | ||
false false false NULL | ||
|
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 am surprised this isn't
I thought if the eq_array is null that means there was at least one comparison that is not known 🤔
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.
The semantics are basically:
So nulls don't matter if there's match, it only matters if there's no match