Skip to content

array_has_any/array_has_all results depend on other rows when needles are NULL #24985

Description

@yashrb24

Describe the bug

array_has_any and array_has_all return different results for the same row
depending on whether another row has a non-empty needle.

To Reproduce

WITH t(id, haystack, needle) AS (
  VALUES
    (1, [1, 2], arrow_cast(NULL, 'List(Int64)')),
    (2, [3, 4], arrow_cast(NULL, 'List(Int64)'))
)
SELECT array_has_any(haystack, needle),
       array_has_all(haystack, needle)
FROM t
ORDER BY id;

This is returning

false true
false true

If the second needle is changed from NULL to something non-null like [9], the first row returns

NULL NULL

Expected behavior

The result should be all nulls

Additional context

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions