Ganesha S created SPARK-58687:
---------------------------------

             Summary:  Support the ANSI SQL/JSON JSON_EXISTS function
                 Key: SPARK-58687
                 URL: https://issues.apache.org/jira/browse/SPARK-58687
             Project: Spark
          Issue Type: Sub-task
          Components: SQL
    Affects Versions: 4.3.0
            Reporter: Ganesha S


Add the ANSI SQL:2016 JSON_EXISTS predicate (feature T821):
{code:java}
  JSON_EXISTS(jsonExpr, path [ (TRUE | FALSE | UNKNOWN | ERROR) ON ERROR 
]){code}
Returns whether the SQL/JSON path matches at least one item:
{code:java}
* path matches (including an explicit JSON null) -> true
* path matches nothing                            -> false
* SQL NULL input                                  -> SQL NULL (Unknown, per 
9075-2 8.23)
* malformed input                                 -> ON ERROR behavior (default 
FALSE){code}
Unlike `get_json_object(...) IS NOT NULL`, it distinguishes "present but null" 
from "absent". The ON ERROR clause selects `TRUE / FALSE / UNKNOWN (a BOOLEAN
NULL) / ERROR`.

Examples:
{code:java}
  JSON_EXISTS('{"a":{"b":1}}', '$.a.b')          -- true
  JSON_EXISTS('{"a":null}', '$.a')               -- true
  JSON_EXISTS('{"a":1}', '$.b')                  -- false
  JSON_EXISTS('not json', '$.a' TRUE ON ERROR){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]

Reply via email to