raminqaf commented on code in PR #29617:
URL: https://github.com/apache/flink/pull/29617#discussion_r4401624817
##########
docs/content.zh/docs/sql/functions/built-in-functions.md:
##########
@@ -233,6 +233,35 @@ A document fails to parse if it:
In all of these cases, `TRY_PARSE_XML` returns `NULL`.
+#### Variant paths
+
+`VARIANT_GET` and `TRY_VARIANT_GET` take a path that names one place in a
Variant. A path starts
+with `$`, the whole value, followed by steps: `.name`, `['name']` or
`["name"]` for a field, and
+`[n]` for an array element. For example, on
+`PARSE_JSON('{"user": {"name": "ada"}, "items": [{"qty": 2}]}')`:
+
+| Path | Points at |
+|---------------------|------------------------------------|
+| `$` | the whole value |
+| `$.user.name` | `"ada"` |
+| `$['user']["name"]` | `"ada"` |
+| `$.items[0].qty` | `2` |
+| `$.items[1]` | nothing, the index is past the end |
+| `$.user[0]` | nothing, `user` is not an array |
+
+- Array indices start at 0, as in `JSON_VALUE`, while `variant[INT]` starts at
1. So `$.items[0]`
+ and `v['items'][1]` are the same element.
+- Use brackets for a name with whitespace or one of the characters `. [ ] ( )
* ' " \`, for example
+ `$['first name']`. Inside the quotes, `\\`, `\'` and `\"` stand for a
backslash and a quote.
Review Comment:
Yes. `$["first name"]` works like `$['first name']`, and inside double
quotes `\"` escapes a double quote. The bullet now says brackets take single or
double quotes and shows both forms.
##########
docs/content.zh/docs/sql/functions/built-in-functions.md:
##########
@@ -233,6 +233,35 @@ A document fails to parse if it:
In all of these cases, `TRY_PARSE_XML` returns `NULL`.
+#### Variant paths
+
+`VARIANT_GET` and `TRY_VARIANT_GET` take a path that names one place in a
Variant. A path starts
+with `$`, the whole value, followed by steps: `.name`, `['name']` or
`["name"]` for a field, and
+`[n]` for an array element. For example, on
+`PARSE_JSON('{"user": {"name": "ada"}, "items": [{"qty": 2}]}')`:
+
+| Path | Points at |
+|---------------------|------------------------------------|
+| `$` | the whole value |
+| `$.user.name` | `"ada"` |
+| `$['user']["name"]` | `"ada"` |
+| `$.items[0].qty` | `2` |
+| `$.items[1]` | nothing, the index is past the end |
+| `$.user[0]` | nothing, `user` is not an array |
+
+- Array indices start at 0, as in `JSON_VALUE`, while `variant[INT]` starts at
1. So `$.items[0]`
+ and `v['items'][1]` are the same element.
+- Use brackets for a name with whitespace or one of the characters `. [ ] ( )
* ' " \`, for example
+ `$['first name']`. Inside the quotes, `\\`, `\'` and `\"` stand for a
backslash and a quote.
+- Wildcards, filters, slices, negative indices and the `lax` and `strict`
modes are not supported,
+ so a path always names one place.
+- Trailing spaces are ignored, so a path read from a `CHAR(n)` column works.
Review Comment:
done
--
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]