ZIP_WITH_INDEX

Combines multiple arrays by index into records

Syntax

ZIP_WITH_INDEX(fieldNames, inputs1[, inputs2, ..., inputsN])

Arguments

NameTypeDescriptionDefault Value

fieldNames

string

Optional comma separated field names

""

inputs#

any

Examples

fieldNamesinputs1inputs2inputs3Output

null::string

array['a', 'b', 'c']

array[1, 2]

array[false, true, false]

[{index: 0, field_1: a, field_2: 1, field_3: false}, {index: 1, field_1: b, field_2: 2, field_3: true}, {index: 2, field_1: c, field_2: null, field_3: false}]

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 fieldNames, inputs1[], inputs2[], inputs3[],
        ZIP_WITH_INDEX(null::string, inputs1[], inputs2[], inputs3[]) AS Output
    FROM default_glue_catalog.upsolver_samples.orders_raw_data
    LET fieldNames = null::string,
        inputs1 = array['a', 'b', 'c'],
        inputs2 = array[1, 2],
        inputs3 = array[false, true, false]
    WHERE $commit_time BETWEEN run_start_time() AND run_end_time()
    LIMIT 1;

Query result

fieldNamesinputs1[]inputs2[]inputs3[]Output

null::string

array['a', 'b', 'c']

array[1, 2]

array[false, true, false]

[{index: 0, field_1: a, field_2: 1, field_3: false}, {index: 1, field_1: b, field_2: 2, field_3: true}, {index: 2, field_1: c, field_2: null, field_3: false}]

Last updated