Lưu ý
Cần có ủy quyền mới truy nhập được vào trang này. Bạn có thể thử đăng nhập hoặc thay đổi thư mục.
Cần có ủy quyền mới truy nhập được vào trang này. Bạn có thể thử thay đổi thư mục.
Applies to:
Databricks SQL
Databricks Runtime
Transforms keys in a map in expr using the function func.
Syntax
transform_keys(expr, func)
Arguments
expr: A MAP expression.func: A lambda function.
Returns
A MAP where the keys have the type of the result of the lambda functions and the values have the type of the expr MAP values.
The lambda function must have 2 parameters. The first parameter represents the key. The second parameter represents the value.
The lambda function produces a new key for each entry in the map.
Examples
> SELECT transform_keys(map_from_arrays(array(1, 2, 3), array(1, 2, 3)), (k, v) -> k + 1);
{2 -> 1, 3 -> 2, 4 -> 3}
> SELECT transform_keys(map_from_arrays(array(1, 2, 3), array(1, 2, 3)), (k, v) -> k + v);
{2 -> 1, 4 -> 2, 6 -> 3}