[
https://issues.apache.org/jira/browse/SPARK-58723?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
ASF GitHub Bot updated SPARK-58723:
-----------------------------------
Labels: pull-request-available (was: )
> [SQL] Support the JSON_QUERY function
> -------------------------------------
>
> Key: SPARK-58723
> URL: https://issues.apache.org/jira/browse/SPARK-58723
> Project: Spark
> Issue Type: Sub-task
> Components: SQL
> Affects Versions: 4.3.0
> Reporter: Ganesha S
> Priority: Major
> Labels: pull-request-available
>
> Add the ANSI SQL:2016 JSON_QUERY function (feature T828): extract a JSON
> fragment (object, array, or serialized scalar) located by a SQL/JSON path and
> return it as JSON text.
> *Syntax:*
>
> {code:java}
> JSON_QUERY(jsonExpr, path
> [ RETURNING <type> ]
> [ (WITHOUT | WITH [CONDITIONAL | UNCONDITIONAL]) ARRAY WRAPPER ]
> [ (KEEP | OMIT) QUOTES ]
> [ (NULL | ERROR | EMPTY ARRAY | EMPTY OBJECT) ON EMPTY ]
> [ (NULL | ERROR | EMPTY ARRAY | EMPTY OBJECT) ON ERROR ]){code}
>
> Semantics:
> * Returns the fragment at `path`, serialized as STRING (VARIANT RETURNING
> deferred).
> * ARRAY WRAPPER wraps the result in [...]; WITH CONDITIONAL only when needed.
> * OMIT QUOTES unquotes a scalar string result.
> * A scalar result is not an error under the default WITHOUT ARRAY WRAPPER
> (JSON_QUERY(j, '$.id') -> 7).
> * ON EMPTY / ON ERROR default to NULL; default path mode is lax.
>
> Examples
> {code:java}
> (j = {"id":7,"name":"Ada","tags":["x","y"],"addr":{"city":"NYC"}}):{code}
>
>
> {code:java}
> JSON_QUERY(j, '$.addr') -- '{"city":"NYC"}'
> JSON_QUERY(j, '$.tags[0]' WITH ARRAY WRAPPER) -- '["x"]'
> JSON_QUERY(j, '$.name' OMIT QUOTES) -- 'Ada'
> JSON_QUERY(j, '$.missing' EMPTY ARRAY ON EMPTY) -- '[]'{code}
>
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]