ARRAY_ENUMERATE_FLATTEN()
All functions > ARRAY > ARRAY_ENUMERATE_FLATTEN()
Returns an array of rows pairing each 1-based position with the flattened fields of the corresponding row element.
Signatures
Returns: Array of rows with index prepended and inner row fields flattened
ARRAY_ENUMERATE_FLATTEN(array: ARRAY<ROW<...>>) → ARRAY<ROW(index BIGINT, ...fields)> sql
| Parameter | Type | Required | Description |
|---|---|---|---|
array | ARRAY<ROW<...>> | Yes | Input array of rows |
Notes
- Index positions start at 1 for the first element
- Preserves element order from the input array
- The input must be an array of rows; use
ARRAY_ENUMERATE()for non-row arrays - Output rows contain
indexfollowed by each field of the original row, in order
See also
Examples
FeatureQL
SELECT
f1 := ARRAY_ENUMERATE_FLATTEN(ARRAY[ROW(10 AS val, 'a' AS lbl), ROW(20 AS val, 'b' AS lbl)]) -- Prepends 1-based index and flattens inner row fields
;Result
| f1 VARCHAR |
|---|
| [{index: 1, val: 10, lbl: a}, {index: 2, val: 20, lbl: b}] |
On this page