Skip to content
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

New array method array_contains #6557

Closed
izveigor opened this issue Jun 6, 2023 · 0 comments · Fixed by #6618
Closed

New array method array_contains #6557

izveigor opened this issue Jun 6, 2023 · 0 comments · Fixed by #6618
Labels
enhancement New feature or request

Comments

@izveigor
Copy link
Contributor

izveigor commented Jun 6, 2023

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

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant