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

Name
Type
Description
Default Value

keys

string

key

string

value

any

Examples

keys
key
value
Output

'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 $commit_time BETWEEN run_start_time() AND run_end_time()
    LIMIT 1;

Query result

keys
key[]
value[]
Output

'foo, hello'

array['foo', 'hello']

array['bar', 'world']

{foo: bar, hello: world}

Last updated