JSON_MAP_TRANSFORM_VALUES
Introduced or updated: v1.2.652
Applies a transformation to each value in a JSON object using a lambda expression.
Syntax
JSON_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 appends " - Special Offer" to each product description:
SELECT JSON_MAP_TRANSFORM_VALUES('{"product1":"laptop", "product2":"phone"}'::VARIANT, (k, v) -> CONCAT(v, ' - Special Offer')) AS promo_descriptions;
┌──────────────────────────────────────────────────────────────────────────┐
│ promo_descriptions │
├──────────────────────────────────────────────────────────────────────────┤
│ {"product1":"laptop - Special Offer","product2":"phone - Special Offer"} │
└──────────────────────────────────────────────────────────────────────────┘