Repository navigation
Closed
Labels
Description
Is your feature request related to a problem?
As part of the RFC to add JSON functions, the json_delete function would be useful to remove elements from json documents by key.
- META RFC: [META]Add PPL
JSONextended functions support #3027 - PPL RFC: [RFC] Add PPL
JSONextended functions support #3028 - Related Spark PPL PR: Support PPL
JSONfunctions: construction and extraction opensearch-spark#780
What solution would you like?
### `JSON_DELETE`
**Description**
`json_delete(doc, path [, path]...)` Deletes json elements from a json document at the specified path(s). Returns the updated document.
**Arguments type:** JSON_OBJECT, STRING
**Return type:** JSON_OBJECT
`json_delete(doc, paths)` Deletes json elements from a json document at the specified paths. Returns the updated document.
**Arguments type:** JSON_OBJECT, ARRAY
**Return type:** JSON_OBJECT
Example:
os> source=people | eval deleted = json_delete(json('{"account_number":1,"balance":39225,"age":32,"gender":"M"}'), array('age','gender')) | head 1 | fields deleted
fetched rows / total rows = 1/1
+------------------------------------------+
| deleted |
+-----------------------------------------+
|{"account_number":1,"balance":39225} |
+-----------------------------------------+
os> source=people | eval deleted = json_delete(json('{"f1":"abc","f2":{"f3":"a","f4":"b"}}'), 'f2.f3') | head 1 | fields deleted
fetched rows / total rows = 1/1
+-----------------------------------------------------------+
| deleted |
+-----------------------------------------------------------+
| {"f1":"abc","f2":{"f4":"b"}} |
+-----------------------------------------------------------+
os> source=people | eval deleted = json_delete(json('{"teacher":"Alice","student":[{"name":"Bob","rank":1},{"name":"Charlie","rank":2}]}'), 'teacher', 'student.rank') | head 1 | fields deleted
fetched rows / total rows = 1/1
+--------------------------------------------------+
| deleted |
+--------------------------------------------------+
|{"student":[{"name":"Bob"},{"name":"Charlie"}]} |
+--------------------------------------------------+
What alternatives have you considered?
N/A
Do you have any additional context?
opensearch-project/opensearch-spark#780 - PR to add json functions to spark ppl
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
LantaoJin commentedon Jun 16, 2025
Resolved by #3559 with Calcite implementation.