Data connectivity & integrationPipeline Builder ExpressionsMap values

Map values

Supported in: Batch, Streaming

Changes the values of the input column to new values based on a map of key-value pairs. If the input value is not found in the map, the default value is used.

Expression categories: Data preparation

Declared arguments

  • Column to replace values in - Column containing the initial values to be mapped to new values.
    Expression<T1>
  • Default value - The default value to be added to the output column if the input value is not found in the map.
    Expression<T2>
  • Values map - Map consisting of key-value pairs. The key of the map is the original value found in the input to be mapped to a new one, whereas the value of the map represents the new value to be replaced with.
    Expression<Map<T1, T2>>

Type variable bounds: T1 accepts ComparableType**T2 accepts AnyType

Output type: T2

Examples

Example 1: Base case

Argument values:

  • Column to replace values in: country
  • Default value: null
  • Values map: {
     Denmark -> DNK,
     United Kingdom -> UK,
    }
countryOutput
United KingdomUK
DenmarkDNK
United States of Americanull

Example 2: Base case

Argument values:

  • Column to replace values in: country
  • Default value: country
  • Values map: {
     Denmark -> DNK,
     United Kingdom -> null,
    }
countryOutput
United Kingdomnull
nullnull