Skip to content

Latest commit

 

History

History
41 lines (30 loc) · 1.14 KB

File metadata and controls

41 lines (30 loc) · 1.14 KB
description
Returns whether a list contains a given value.

ARRAY_CONTAINS

Syntax

ARRAY_CONTAINS(list LIST, value any) → boolean

  • list: The list to search.
  • value: An expression of a type that is comparable with the LIST.

Examples

{% code title="ARRAY_CONTAINS example" %}

SELECT ARRAY_CONTAINS(CONVERT_FROM('["apple", "pear", "banana"]', 'json'), NULL)
-- null

{% endcode %}

{% code title="ARRAY_CONTAINS example" %}

SELECT ARRAY_CONTAINS(CONVERT_FROM('["apple", "pear", "banana"]', 'json'), 'pear')
-- true

{% endcode %}

{% code title="ARRAY_CONTAINS example" %}

SELECT ARRAY_CONTAINS(CONVERT_FROM('["apple", "pear", "banana"]', 'json'), 'grape')
-- false

{% endcode %}

Usage Notes

If value is NULL, the result is NULL. If NULL is in list and value is not in list, the result is NULL. If value is present in the list, the result is TRUE. Otherwise, the result is FALSE.

\