Transforms the values in Map input by using func. The keys in the map are not changed.
Syntax
map<K, V2> transform_values(map<K, V1> <input>, function<K, V1, V2> <func>)
Parameters
input: required. This parameter specifies a map.
K
andV1
inmap<K, V1>
specify the keys and values of the map.func: required. This parameter specifies the built-in function, user-defined function, or expression that is used to transform the values. The function or expression consists of two input parameters that correspond to the keys and values in input.
V2
specifies the data type of values in the returned map.
Return value
Data of the MAP type is returned.
Examples
-- The return value is {-30:71, 10:-10, 20:null}.
select transform_values(map(10, -20, 20, null, -30, 101), (k, v) -> k + v);
In this example, the combination of a hyphen and a closing angle bracket (->)
is used. For more information about how to use the combination of a hyphen and a closing angle bracket(->)
in Lambda functions, see Lambda functions.
Related functions
TRANSFORM_VALUES is a complex type function. For more information about the functions that are used to process data of complex data types, such as ARRAY, MAP, STRUCT, and JSON, see Complex type functions.