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
    -- Flatten numeric arrays
    f1 := FLATTEN(ARRAY(1, 2, 3), ARRAY(4, 5, 6)),
    -- Flatten string arrays
    f2 := FLATTEN(ARRAY('A', 'B'), ARRAY('C'), ARRAY('D', 'E')),
    -- Empty arrays ignored
    f3 := FLATTEN(ARRAY()::BIGINT[], ARRAY(1, 2), ARRAY()::BIGINT[])
;
Result
f1 ARRAYf2 ARRAYf3 ARRAY
[1, 2, 3, 4, 5, 6][A, B, C, D, E][1, 2]

Last update at: 2026/06/20 10:08:10