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 to_json_string function to PPL #3210

Open
acarbonetto opened this issue Dec 18, 2024 · 0 comments
Open

[FEATURE] Add to_json_string function to PPL #3210

acarbonetto opened this issue Dec 18, 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 to_json_string function would be useful to convert json objects into json-encoded strings.

What solution would you like?

### `TO_JSON_STRING`

**Description**

`to_json_string(doc)` Returns a JSON string representing the given json_document object.

**Argument type:** JSON_OBJECT

**Return type:** STRING

Example:

    os> source=people | eval `json_string` = to_json_string(json_array(1, 2, 0, -1, 1.1, -0.11)) | fields json_string
    fetched rows / total rows = 1/1
    +--------------------------------+
    | json_string                    |
    +--------------------------------+
    | [1.0,2.0,0.0,-1.0,1.1,-0.11]   |
    +--------------------------------+

    os> source=people | eval `json_string` = to_json_string(json_object('key', 123.45)) | fields json_string
    fetched rows / total rows = 1/1
    +-----------------+
    | json_string     |
    +-----------------+
    | {'key', 123.45} |
    +-----------------+

What alternatives have you considered?

N/A

Do you have any additional context?

opensearch-project/opensearch-spark#870 - PR to add json objects to opensearch-spark PPL

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

2 participants