-
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
Changes from all commits
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 | ||
|
||
# Always return false if not contained even if list has null elements | ||
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); | ||
---- | ||
false false | ||
|
||
#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 | ||
false | ||
false | ||
|
||
query B | ||
select array_has(column1, column2) | ||
from fixed_size_array_has_table_1D; | ||
|
@@ -5574,9 +5601,9 @@ false false false true | |
true false true false | ||
true false false true | ||
false true false false | ||
NULL NULL false false | ||
false false NULL false | ||
false false false NULL | ||
false false false false | ||
false false false false | ||
false false false false | ||
|
||
query BBBBBBBBBBBBB | ||
select array_has_all(make_array(1,2,3), make_array(1,3)), | ||
|
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.
this is not a behavior change I don't think - just a refactor
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.
Yeah this was just matching the style of the other