[ https://issues.apache.org/jira/browse/CALCITE-2892?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16808291#comment-16808291 ]
Hongze Zhang commented on CALCITE-2892: --------------------------------------- Thank you for taking this, [~x1q1j1]! So far the PR looks good to me, and I've added some minor changes, please take a look at the [branch|https://github.com/zhztheplayer/calcite/commit/939cd9417bab48ec1b571caefda4c15df31d43b8]. The minor changes list: * reformatted reserved and non-reserved keyword list a bit; * simplified some unparse method on JSON operators; * simplified first several code lines from method SqlFunctions#jsonKeys. > Add the JSON_KEYS function > -------------------------- > > Key: CALCITE-2892 > URL: https://issues.apache.org/jira/browse/CALCITE-2892 > Project: Calcite > Issue Type: Sub-task > Reporter: Forward Xu > Assignee: Forward Xu > Priority: Major > Labels: pull-request-available > Fix For: 1.20.0 > > Time Spent: 2h 50m > Remaining Estimate: 0h > > [{{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)