ARRAY_CONTAINS
functionsupportedCore SQL functionsReturns TRUE if the specified value is found in the specified array.
Syntax
ARRAY_CONTAINS( <value_expr> , <array> )
Parameters
| Name | Required | Description |
|---|---|---|
value_expr | required | Value to find in array. If array is a semi-structured array, value_expr must evaluate to a VARIANT. If array is a structured array, value_expr must evaluate to a type that is comparable to the type of the array. |
array | required | The array to search. |
Returns
This function returns a value of BOOLEAN type or NULL: - The function returns TRUE if value_expr is present in array, including the following cases: When the value_expr argument is NULL and there is a SQL NULL value in the array (undefined). - When the value_expr argument is JSON null and there is a JSON null value in the array (null). - The function returns FALSE if value_expr isn’t present in array, including when the value_expr argument is JSON null and there are no JSON null values in the array. - The function returns NULL if the value_expr argument is NULL and there are no SQL NULL values in the array. For more information about NULL values in arrays, see NULL values.
Usage notes
- The function does not support wildcards in value_expr. However, you can use the ARRAY_TO_STRING function to convert an array to a string, then search the string with wildcard characters. For example, you can specify wildcards to search the returned string using the [ NOT ] LIKE and REGEXP_LIKE functions.
- If array is a semi-structured array, explicit casting of the value_expr value to a VARIANT value is required for values of the following data types: String & binary
- Date & time
- The following example explicitly casts a string value to a VARIANT value:
- Explicit casting isn’t required for values of other data types.