JSON_MAP_TRANSFORM_VALUES (Lakehouse v1)
Applies a transformation to each value in a JSON object using a lambda expression.
SQL Syntax
Section titled “SQL Syntax”JSON_MAP_TRANSFORM_VALUES(<json_object>, (<key>, <value>) -> <value_transformation>)Return Type
Section titled “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.
SQL Examples
Section titled “SQL 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"} │└──────────────────────────────────────────────────────────────────────────┘