Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] Add json function to cast nested to json object #3216

Open
3 tasks
acarbonetto opened this issue Dec 19, 2024 · 0 comments
Open
3 tasks

[FEATURE] Add json function to cast nested to json object #3216

acarbonetto opened this issue Dec 19, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@acarbonetto
Copy link
Collaborator

Is your feature request related to a problem?

As part of the RFC to add JSON functions, the json() function would be useful to cast a nested object as a JSON_OBJECT using the json() function or cast(nested to json) syntax.

What solution would you like?

  • Add the json(nested) function that constructs a JSON_OBJECT from a nested object
  • Add the cast(nested to json) casting syntax to cast a nested object to a JSON_OBJECT
  • Update documentation and mapping
### `JSON`

**Description**

`json(value)` Unnests a NESTED object and casts it into a JSON object. 

**Argument type:** NESTED OBJECT

**Return type:** JSON OBJECT

Example:

    os> source=people | eval unnested_json = json(nested) | fields unnested_json
    fetched rows / total rows = 1/1
    +---------------------------------+
    | unnested_json                      |
    +---------------------------------+
    | {'name': 'Timmy', 'location': 'Seattle'   |
    +---------------------------------+

JSON Cast:

Example:

    os> source=people | eval unnested_json = cast(nested to json) | fields unnested_json
    fetched rows / total rows = 1/1
    +---------------------------------+
    | unnested_json                      |
    +---------------------------------+
    | {'name': 'Timmy', 'location': 'Seattle'   |
    +---------------------------------+

What alternatives have you considered?

N/A

Do you have any additional context?

opensearch-project/opensearch-spark#780 - PR to add feature to opensearch-spark PPL

@acarbonetto acarbonetto added enhancement New feature or request untriaged labels Dec 19, 2024
@acarbonetto acarbonetto changed the title [FEATURE] Add json function to cast nested to json object #3209 [FEATURE] Add json function to cast nested to json object Dec 19, 2024
@acarbonetto acarbonetto changed the title [FEATURE] Add json function to cast nested to json object [FEATURE] Add json function to cast nested to json object Dec 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant