JSON_OBJECT_DELETE (Lakehouse v1)
Deletes specified keys from a JSON object and returns the modified object. If a specified key doesn’t exist in the object, it is ignored.
SQL Syntax
Section titled “SQL Syntax”json_object_delete(<json_object>, <key1> [, <key2>, ...])Parameters
Section titled “Parameters”| Parameter | Description |
|---|---|
| json_object | A JSON object (VARIANT type) from which to delete keys. |
| key1, key2, … | One or more string literals representing the keys to be deleted from the object. |
Return Type
Section titled “Return Type”Returns a VARIANT containing the modified JSON object with specified keys removed.
SQL Examples
Section titled “SQL Examples”Delete a single key:
SELECT json_object_delete('{"a":1,"b":2,"c":3}'::VARIANT, 'a');-- Result: {"b":2,"c":3}Delete multiple keys:
SELECT json_object_delete('{"a":1,"b":2,"d":4}'::VARIANT, 'a', 'c');-- Result: {"b":2,"d":4}Delete a non-existent key (key is ignored):
SELECT json_object_delete('{"a":1,"b":2}'::VARIANT, 'x');-- Result: {"a":1,"b":2}