Airblader commented on a change in pull request #16858:
URL: https://github.com/apache/flink/pull/16858#discussion_r702764140
##########
File path: docs/data/sql_functions_zh.yml
##########
@@ -799,6 +798,46 @@ json:
JSON_VALUE('{"a": true}', 'strict $.b'
DEFAULT FALSE ON ERROR)
```
+ - sql: JSON_QUERY(jsonValue, path [ { WITHOUT | WITH CONDITIONAL | WITH
UNCONDITIONAL } [ ARRAY ] WRAPPER ] [ { NULL | EMPTY ARRAY | EMPTY OBJECT |
ERROR } ON EMPTY ] [ { NULL | EMPTY ARRAY | EMPTY OBJECT | ERROR } ON ERROR ])
+ table: STRING.jsonQuery(path [, JsonQueryWrapper [,
JsonQueryOnEmptyOrError, JsonQueryOnEmptyOrError ] ])
+ description: |
+ Extracts JSON values from a JSON string.
+
+ The result is always returned as a `STRING`. The `RETURNING` clause is
currently not supported.
+
+ The `wrappingBehavior` determines whether the extracted value should be
wrapped into an array,
+ and whether to do so unconditionally or only if the value itself isn't
an array already.
+
+ `onEmpty` and `onError` determine the behavior in case the path
expression is empty, or in
+ case an error was raised, respectively. By default, in both cases `null`
is returned. Other
+ choices are to use an empty array, an empty object, or to raise an error.
+
+ ```
+ -- '{ "b": 1 }'
+ JSON_QUERY('{ "a": { "b": 1 } }', '$.a')
+ -- '[1, 2]'
+ JSON_QUERY('[1, 2]', '$')
+
+ -- Wrap result into an array
+ -- '[{}]'
+ JSON_QUERY('{}', '$' WITH CONDITIONAL ARRAY WRAPPER)
Review comment:
The `ARRAY` keyword is optional and only for expresiveness; there is no
difference in behavior either way.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]