Forward Xu created CALCITE-2892:
-----------------------------------

             Summary: Add the JSON_KEYS function
                 Key: CALCITE-2892
                 URL: https://issues.apache.org/jira/browse/CALCITE-2892
             Project: Calcite
          Issue Type: New Feature
            Reporter: Forward Xu


[{{JSON_KEYS(_{{json_doc}}_[, 
_{{path}}_])}}|https://dev.mysql.com/doc/refman/5.7/en/json-search-functions.html#function_json-keys]

Returns the keys from the top-level value of a JSON object as a JSON array, or, 
if a _{{path}}_ argument is given, the top-level keys from the selected path. 
Returns {{NULL}} if any argument is {{NULL}}, the _{{json_doc}}_ argument is 
not an object, or _{{path}}_, if given, does not locate an object. An error 
occurs if the _{{json_doc}}_argument is not a valid JSON document or the 
_{{path}}_ argument is not a valid path expression or contains a {{*}} or 
{{**}} wildcard.

The result array is empty if the selected object is empty. If the top-level 
value has nested subobjects, the return value does not include keys from those 
subobjects.

Example SQL:
{code:java}
// code placeholder
SELECT JSON_KEYS(v) AS c1
,JSON_KEYS(v, 'lax $.a') AS c2
,JSON_KEYS(v, '$.b') AS c3
,JSON_KEYS(v, 'strict $.a[0]') AS c4
,JSON_KEYS(v, 'strict $.a[1]') AS c5
FROM (VALUES ('{"a": [10, true],"b": {"c": 30}}')) AS t(v)
LIMIT 10;
{code}
Result:
||c1||c2||c3||c4||c5||
|["a", "b"]|[NULL]|["c"]|[NULL]|[NULL]|



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to