Skip to content

[FEATURE] Support Json related functions #3565

Closed

Description

@xinyual

Is your feature request related to a problem?
In spark we have json related functions https://github.com/opensearch-project/opensearch-spark/blob/main/docs/ppl-lang/functions/ppl-json.md, we also want it in opensearch PPL.

Activity

  1. added
    enhancement
    on Apr 21, 2025
  2. changed the title [-][FEATURE] Support Json like functions[/-] [+][FEATURE] Support Json related functions[/+] on Apr 21, 2025
  3. added
    calcite
    and removed on Apr 22, 2025
  4. xinyual commented on Apr 22, 2025

    @xinyual
    ContributorAuthor

    But I find the performance of some spark functions are wired. We need to discuss its performance. I write my expectation for this function

    Functions json path input ? ('$.f1.f2') support regex input? ('$.f1[*].f2') perform when json path point to null perform when father path point to null
    json_extract Y Y return null return null
    json_set Y Y do insert anyway do nothing
    json_delete Y Y do nothing do nothing
    json_append Y Y do nothing do nothing
    json_extend Y Y do nothing do nothing

    And here is the spark's performance

    Functions json path input ? ('$.f1.f2') support regex input? ('$.f1[*].f2') perform when json path point to null perform when father path point to null
    json_extract Y Y return null return null
    json_set N N insert anyway insert anyway
    json_delete N N do nothing do nothing
    json_append N N the value are added to the root of the json tree the value are added to the root of the json tree
    json_extend N N the value are added to the root of the json tree the value are added to the root of the json tree

    And here are the functions in calcite

    Functions corresponding calcite implementation json path input ? ('$.f1.f2') support regex input? ('$.f1[*].f2') perform when json path point to null perform when father path point to null
    json_extract json_value/json_query Y N. json_value return scalar while json_query return object/array. We need a combination return null return null
    json_set Json_set Y N. Calcite use JsonPath.isPathDefinite do insert anyway do nothing
    json_delete json_remove Y N. Calcite use JsonPath.isPathDefinite do nothing do nothing
    json_append json_insert Y N. Calcite use JsonPath.isPathDefinite do nothing do nothing
    json_extend / / / / /

    BTW, for json_append and json_extend, the only difference is when the target object the json path pointed is an array and candidate input is also an array, append would directly add it as [a, b, [candidate1, candidate2]] while extend would [a, b, candidate, candidate..] can we implement only one command? Looks the calcite only support json_append using sqlLibraryOperators.JSON_INSERT

  5. xinyual commented on Apr 22, 2025

    @xinyual
    ContributorAuthor
  6. penghuo commented on Apr 29, 2025

    @penghuo
    Collaborator

    json_extract

    in opensearch-spark, current json_extract return string, the expectation is ARRAY or PPL scaler data type?

  7. added
    PPL
    on May 30, 2025
  8. moved this from Not Started to Done in PPL Trackeron Jun 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

PPLSeverity-Blockercalciteenhancement

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions