REMAP_VALUES
Description
REMAP_VALUES
allows you to map values of a column of type STRING.
Syntax
REMAP_VALUES ( table.column, [ old_value1, new_value1 ] , ... [, others_value ] )
The first parameter of REMAP_VALUES
is an input column of type STRING that provides the values that should be remapped. The second parameter is a list of one or more pairs of STRING values that describe the mapping. Each occurrence of the first value of the pair will be remapped to the second value of the pair. If a value is remapped in multiple pairs, only the last pair is used. Finally, the operator accepts an optional STRING value that will replace all values that are not remapped within the mapping. If this optional default replacement value is missing, all values not considered in the mapping will remain unchanged.
As the REMAP_VALUES
operator is only applicable to columns of type STRING, REMAP_INTS provides a similar functionality for columns of type INT.
You can achieve the same result with a CASE WHEN statement but REMAP_VALUES
is faster and the syntax is more compact.
REMAP_VALUES
is often used to ignore certain activities in process functions by setting those activities to NULL, for example in the SOURCE and TARGET filter column.
NULL handling
If the input value is NULL and it is not mapped to any other value, REMAP_VALUES
will return NULL again.
Use Cases
REMAP_VALUES
can be used for Segregation of Duties.
Examples
[1] Simple example of the | ||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||
|
[2] In this example, 'a' is remapped to NULL, and NULL values are mapped to 'c'. Note that the mappings are not applied incrementally; only the last matching mapping for each input row is applied: | ||||||||||||||
| ||||||||||||||
|
[3] In this example, | ||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||
|