FLATTEN(...)
All functions > ARRAY > FLATTEN(...)
Flattens a nested array structure into a single-level array.
Syntax
FLATTEN(array, array, ...)
Notes
- Flattens one level of nesting
- Preserves element order
- Works with any array element type
- Empty nested arrays are removed from result
See also
Examples
FeatureQL
SELECT
f1 := FLATTEN(ARRAY[1, 2, 3], ARRAY[4, 5, 6]), -- Flatten numeric arrays
f2 := FLATTEN(ARRAY['A', 'B'], ARRAY['C'], ARRAY['D', 'E']), -- Flatten string arrays
f3 := FLATTEN(ARRAY[]::BIGINT[], ARRAY[1, 2], ARRAY[]::BIGINT[]) -- Empty arrays ignored
;Result
| f1 ARRAY | f2 ARRAY | f3 ARRAY |
|---|---|---|
| [1, 2, 3, 4, 5, 6] | [A, B, C, D, E] | [1, 2] |