Links

ZIP

Merges the given arrays, element-wise, into a single array of rows.

Syntax

ZIP(ARRAY1, ARRAY2 [, ...])

Arguments

ARRAY

Type: array
A array of values of any type.

Returns

Type: array
The given arrays merged element-wise into a single array of rows.
The M-th element of the N-th argument will be the N-th field of the M-th output element. If the arguments have an uneven length, missing values are filled with NULL.

Examples

Transformation job example

SQL

CREATE JOB function_operator_example
ADD_MISSING_COLUMNS = true
AS INSERT INTO default_glue_catalog.upsolver_samples.orders_transformed_data MAP_COLUMNS_BY_NAME
SELECT
ZIP(ARRAY[1, 2], ARRAY['1b', null::string, '3b']) AS zip_example1,
ZIP(ARRAY['a', 'b', 'c'], ARRAY[1, 2], ARRAY[false, true, false]) AS zip_example2
FROM default_glue_catalog.upsolver_samples.orders_raw_data
WHERE time_filter()
LIMIT 1;

Query result

zip_example1
zip_example2
[{"field0":1,"field1":"1b"},{"field0":2,"field1":"3b"}]
[{"field0":"a","field1":1,"field2":false},{"field0":"b","field1":2,"field2":true},{"field0":"c","field2":false}]