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_valid as a PPL function #3207

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

[FEATURE] Add json_valid as a PPL function #3207

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

Comments

@acarbonetto
Copy link
Collaborator

acarbonetto commented Dec 18, 2024

Is your feature request related to a problem?
As part of the RFC to add JSON functions, the json_valid function would be useful to validate incoming json-encoded strings.

What solution would you like?

Note: The Jackson data-bind library is already available in opensearch-sql to validate json-encoded strings.

### `JSON_VALID`

**Description**

`json_valid(jsonStr)` Evaluates whether a json-encoded string contains valid JSON syntax and returns TRUE or FALSE.

**Argument type:** STRING

**Return type:** BOOLEAN

Example:

    os> source=people | eval `valid_json` = json_valid('[1,2,3,4]'), `invalid_json` = json_valid('{"invalid": "json"') | fields `valid_json`, `invalid_json`
    fetched rows / total rows = 1/1
    +--------------+----------------+
    | valid_json   | invalid_json   |
    +--------------+----------------+
    | True         | False          |
    +--------------+----------------+

    os> source=accounts | where json_valid('[1,2,3,4]') and isnull(email) | fields account_number, email
    fetched rows / total rows = 1/1
    +------------------+---------+
    | account_number   | email   |
    |------------------+---------|
    | 13               | null    |
    +------------------+---------+

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

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