[
https://issues.apache.org/jira/browse/SPARK-58793?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Vinod KC updated SPARK-58793:
-----------------------------
Summary: Support ANSI SQL `IS [NOT] JSON` predicate (was: Support ANSI SQL
IS [NOT] JSON predicate)
> Support ANSI SQL `IS [NOT] JSON` predicate
> ------------------------------------------
>
> Key: SPARK-58793
> URL: https://issues.apache.org/jira/browse/SPARK-58793
> Project: Spark
> Issue Type: Sub-task
> Components: SQL
> Affects Versions: 4.4.0
> Reporter: Vinod KC
> Priority: Minor
>
> ANSI SQL defines the IS [NOT] JSON predicate for checking whether a string
> is well-formed JSON, with an optional shape qualifier constraining the
> top-level type:
> {code:java}
> expr IS [NOT] JSON [VALUE | ARRAY | OBJECT | SCALAR]{code}
> {*}Shape qualifiers{*}:
> * (none) / VALUE – any well-formed JSON value; VALUE is equivalent to the
> unqualified form
> * OBJECT – well-formed JSON object ( \{...})
> * ARRAY – well-formed JSON array ([...])
> * SCALAR – JSON primitive only: string, number, boolean, or null (not
> object/array)
> IS NOT JSON is the negation of IS JSON and accepts the same optional
> qualifier.
>
> *Behavior:*
> {code:sql}
> SELECT '{"a":1}' IS JSON -- true
> SELECT '[1,2]' IS JSON ARRAY -- true
> SELECT '{"a":1}' IS JSON VALUE -- true (VALUE accepts objects, arrays,
> and scalars)
> SELECT '{"a":1}' IS JSON SCALAR -- false (SCALAR rejects objects and
> arrays)
> SELECT '42' IS JSON SCALAR -- true
> SELECT 'null' IS JSON SCALAR -- true (JSON null literal is a scalar)
> SELECT '{"a":1}' IS JSON ARRAY -- false
> SELECT 'bad' IS JSON -- false
> SELECT 'bad' IS NOT JSON -- true
> SELECT NULL IS JSON -- NULL (three-valued logic: NULL
> propagates)
> {code}
>
> Note: IS JSON vs JSON_EXISTS
> These are different predicates. IS JSON checks whole-value well-formedness
> with no path navigation. JSON_EXISTS navigates inside a JSON document using
> a path expression and checks for the existence of a matching node.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]