Skip to main content

MAP_TRANSFORM_VALUES

Introduced or updated: v1.2.762

Applies a transformation to each value in a JSON object using a lambda expression.

Syntax​

MAP_TRANSFORM_VALUES(<json_object>, (<key>, <value>) -> <value_transformation>)

Return Type​

Returns a JSON object with the same keys as the input JSON object, but with values modified according to the specified lambda transformation.

Examples​

This example multiplies each numeric value by 10, transforming the original object into {"a":10,"b":20}:

SELECT MAP_TRANSFORM_VALUES('{"a":1,"b":2}'::VARIANT, (k, v) -> v * 10) AS transformed_values;

┌────────────────────┐
│ transformed_values │
├────────────────────┤
│ {"a":10,"b":20} │
└────────────────────┘
Try Databend Cloud for FREE

Multimodal, object-storage-native warehouse for BI, vectors, search, and geo.

Snowflake-compatible SQL with automatic scaling.

Sign up and get $200 in credits.

Try it today