Skip to content

New array method array_contains #6557

Closed
@izveigor

Description

@izveigor

Is your feature request related to a problem or challenge?

Follow on to #6384

The function array_contains was proposed @bubbajoe in #6075.

Describe the solution you'd like

We have two arrays: first_array and second_array.
The main concept of the function is to check all elements of first_array for presence in second_array (dimensions and iorder of elements do not affect the result).

Examples:

select array_contains(make_array(1, 4, 3), make_array(3, 1, 3));
----
t

Describe alternatives you've considered

We can use PostgreSQL operations for checking elements of first array in second array (See https://www.postgresql.org/docs/current/functions-array.html):

select make_array(1, 4, 3) @> array(3, 1, 3);
----
t
select make_array(2, 2, 7) <@ make_array(1, 7, 4, 2, 6);
----
t

We can use array_contains for only one element (like contains method in Rust), but I think it would be better to use the check elements of the first array in the second array (But the idea to use two options is not refuted)

Additional context

Similar Issues:
#6075

Similar PR:
#6384

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions