Returns the 0-based index of the first occurrence of an element in an array. Returns NULL if the element is not found or if the search value is NULL.Syntax:ARRAY_POSITION(array, value)
-- Find the position of an elementSELECT ARRAY_POSITION(ARRAY('john', 'jack', 'jill'), 'jack') -- 1-- Use with a dataset columnSELECT ARRAY_POSITION(tags, 'premium') AS premium_indexFROM company_data."123"-- Returns NULL when not foundSELECT ARRAY_POSITION(ARRAY('a', 'b', 'c'), 'z') -- NULL
ARRAY_POSITION uses 0-based indexing, so the first element is at position 0.
Filters elements of an array using a lambda predicate. Returns a new array containing only elements for which the lambda returns true.Syntax:FILTER(array, element -> condition)
-- Keep only elements matching a conditionSELECT FILTER(tags, t -> t = 'active') AS active_tagsFROM company_data."123"-- Filter with IN operatorSELECT FILTER(names, n -> n IN ('john', 'jack')) AS matched_namesFROM company_data."123"-- Combine FILTER with other array functionsSELECT SIZE(FILTER(tags, t -> t = 'premium')) AS premium_countFROM company_data."123"
Applies a function to each element of an array, returning a new array of transformed values.Syntax:TRANSFORM(array, element -> expression)
-- Uppercase every elementSELECT TRANSFORM(names, n -> UPPER(n)) AS upper_namesFROM company_data."123"-- Extract a field from an array of structsSELECT TRANSFORM(items, x -> x."name") AS item_namesFROM company_data."123"-- Chain FILTER and TRANSFORM togetherSELECT TRANSFORM(FILTER(names, x -> x IN ('john', 'jack')), n -> UPPER(n)) AS resultFROM company_data."123"