Skip to main content

Categories: Semi-Structured Data

ARRAY_POSITION

Returns the index of the first occurrence of an element in an array.

Syntax

ARRAY_POSITION(element ANY, arr LIST) → numeric

  • element: Element to find in the array.
  • arr: The array to search.

Examples

ARRAY_POSITION example
SELECT ARRAY_POSITION(CAST(3 AS BIGINT), ARRAY[1, 2, 3])
-- 2
ARRAY_POSITION example
SELECT ARRAY_POSITION(4, ARRAY[1, 2, 3])
-- NULL
array_col contains ARRAY[1, NULL, 3]
SELECT ARRAY_POSITION(NULL, array_col)
-- 1
ARRAY_POSITION example
SELECT ARRAY_POSITION(ARRAY[2,3], ARRAY[ARRAY[1,2], ARRAY[2,3]])
-- 1