JSON_MAP_TRANSFORM_KEYS (Lakehouse v1)
Applies a transformation to each key in a JSON object using a lambda expression.
SQL Syntax
Section titled “SQL Syntax”JSON_MAP_TRANSFORM_KEYS(<json_object>, (<key>, <value>) -> <key_transformation>)Return Type
Section titled “Return Type”Returns a JSON object with the same values as the input JSON object, but with keys modified according to the specified lambda transformation.
SQL Examples
Section titled “SQL Examples”This example appends “_v1” to each key, creating a new JSON object with modified keys:
SELECT JSON_MAP_TRANSFORM_KEYS('{"name":"John", "role":"admin"}'::VARIANT, (k, v) -> CONCAT(k, '_v1')) AS versioned_metadata;
┌──────────────────────────────────────┐│ versioned_metadata │├──────────────────────────────────────┤│ {"name_v1":"John","role_v1":"admin"} │└──────────────────────────────────────┘