Categories:

Semi-structured and Structured Data Functions (Array/Object)

ARRAY_CONTAINS

Returns TRUE if the specified value is found in the specified ARRAY.

Syntax

ARRAY_CONTAINS( <value_expr> , <array> )
Copy

Arguments

value_expr

Value to find in array.

array

The ARRAY to search.

Returns

The function returns TRUE if value is present in array.

Examples

The following queries demonstrate basic usage of the ARRAY_CONTAINS function:

SELECT ARRAY_CONTAINS('hello'::variant, array_construct('hello', 'hi'));
+------------------------------------------------------------------+
| ARRAY_CONTAINS('HELLO'::VARIANT, ARRAY_CONSTRUCT('HELLO', 'HI')) |
|------------------------------------------------------------------|
| True                                                             |
+------------------------------------------------------------------+
Copy
SELECT ARRAY_CONTAINS('hello'::variant, array_construct('hola', 'bonjour'));
+----------------------------------------------------------------------+
| ARRAY_CONTAINS('HELLO'::VARIANT, ARRAY_CONSTRUCT('HOLA', 'BONJOUR')) |
|----------------------------------------------------------------------|
| False                                                                |
+----------------------------------------------------------------------+
Copy