Replace ANY/ALL CASE planning with array_has/min/max desugaring#22102
Replace ANY/ALL CASE planning with array_has/min/max desugaring#22102cetra3 wants to merge 1 commit into
Conversation
|
FYI @buraksenn @berkaysynnada and @Jefffrey Perhaps you can help review this PR as you helped review #21743 |
Jefffrey
left a comment
There was a problem hiding this comment.
So do we have a comprehensive view of how empty haystacks/null haystacks/haystacks containing nulls/null needles look with any/all and all supported operators with this PR?
I've lost track a bit of how the behaviour has evolved over the PRs:
So I want to ensure we have a clear understanding of the final behaviour we're agreeing on, since this PR is fixing the any = behaviour to what it previously was and hopefully aligning the other operators (and all) to similar behaviour it seems?
| ---- | ||
| NULL | ||
|
|
||
| # Mixed NULL + non-NULL (non-NULL elements satisfy, but NULLs present → NULL) |
There was a problem hiding this comment.
We'd need to adjust this comment on these test cases
| @@ -145,7 +145,7 @@ | |||
| query B | |||
| select 5 <> ALL(make_array(NULL::INT, NULL::INT)); | |||
There was a problem hiding this comment.
This test case has changed behaviour so should be moved out from under the parent comment (All-NULL arrays: returns NULL)
Which issue does this PR close?
= ANY([literals])#22073Rationale for this change
This partially reverts the changes in PR #21743 but keeps the cardinality when desugaring to
array_minandarray_maxvalues.This aligns more with the outputs from the existing datafusion functions, rather than going down the path of having full on PostgreSQL null semantics.
What changes are included in this PR?
Adjusts how we desugar certain queries such as
> ANYetc.. rather than using a full chain, we use a simplified version that just checks the cardinality first and combines witharray_min/array_maxoperatorsI.e,
Desugars to:
Which get simplified to:
Are these changes tested?
Yes they are tested
Are there any user-facing changes?
Yes, there are some changes to the output of some queries.
However these changes were not shipped as part of
53.1.0, and are only onmain