FROM_KEY_VALUE

Maps a list of key values to a record with fields for each key

Syntax

FROM_KEY_VALUE(keys, key, value)

Arguments

NameTypeDescriptionDefault Value

keys

string

key

string

value

any

Examples

keyskeyvalueOutput

'foo, hello'

array['foo', 'hello']

array['bar', 'world']

{foo: bar, hello: world}

'foo, hello'

array['foo', 'hoo']

array['bar', 'zoo']

{foo: bar, hello: null}

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 keys, key[], value[],
        FROM_KEY_VALUE('foo, hello', key[], value[]) AS Output
    FROM default_glue_catalog.upsolver_samples.orders_raw_data
    LET keys = 'foo, hello',
        key = array['foo', 'hello'],
        value = array['bar', 'world']
    WHERE time_filter()
    LIMIT 1;

Query result

keyskey[]value[]Output

'foo, hello'

array['foo', 'hello']

array['bar', 'world']

{foo: bar, hello: world}

Last updated