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 exampleSELECT ARRAY_POSITION(CAST(3 AS BIGINT), ARRAY[1, 2, 3])
-- 2
SELECT ARRAY_POSITION(4, ARRAY[1, 2, 3])
-- NULL
SELECT ARRAY_POSITION(NULL, array_col)
-- 1
SELECT ARRAY_POSITION(ARRAY[2,3], ARRAY[ARRAY[1,2], ARRAY[2,3]])
-- 1