ZIP(...)

All functions > ARRAY OF ROWS > ZIP(...)

Combines multiple arrays into a single array of structured rows with named fields.

Syntax

ZIP(array [ AS field_name ] [, array [ AS field_name ] ...])

Notes

  • Combines arrays element-by-element into rows
  • Uses longest array length, pads shorter arrays with NULL
  • Can specify custom field names with AS clause
  • Default field names are field_1, field_2, etc.
  • Generic type: (Array(T1), Array(T2), ...) → Array(Row(field_1: T1, field_2: T2, ...))

See also

Examples

FeatureQL
SELECT
    f1 := ZIP(ARRAY[1, 2, 3]), -- Zip single array into rows
    f2 := ZIP(ARRAY[1, 2, 3], ARRAY['a', 'b', 'c']), -- Zip two arrays into rows
    f3 := ZIP(ARRAY[1, 2, 3], ARRAY['a', 'b']) -- Zip arrays of different lengths
;
Result
f1 VARCHARf2 VARCHARf3 VARCHAR
[{field_1: 1}, {field_1: 2}, {field_1: 3}][{field_1: 1, field_2: a}, {field_1: 2, field_2: b}, {field_1: 3, field_2: c}][{field_1: 1, field_2: a}, {field_1: 2, field_2: b}, {field_1: 3, field_2: null}]

Last update at: 2026/05/26 17:22:09