Skip to content

[FEATURE] Add json_delete function to PPL #3213

Closed

Description

@acarbonetto

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.

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

Activity

  1. added
    PPL
    on May 29, 2025
  2. LantaoJin commented on Jun 16, 2025

    @LantaoJin
    Member

    Resolved by #3559 with Calcite implementation.

  3. moved this from Not Started to Done in PPL Trackeron Jun 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    PPLenhancement

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions