raminqaf commented on code in PR #29617:
URL: https://github.com/apache/flink/pull/29617#discussion_r4401633501
##########
docs/data/sql_functions.yml:
##########
@@ -1451,13 +1451,69 @@ variant:
- sql: variant '[' INT ']'
table: VARIANT.at(INT)
description: |
- If the VARIANT is an ARRAY value, returns a VARIANT whose value is the
element at
- the specified index. The index starts from 1, If the index is out of
range, it returns NULL.
+ If the VARIANT is an array, returns a VARIANT holding the element at the
index. The index
+ starts at 1. If the index is out of range, returns NULL. If the VARIANT
is not an array, an
+ error is thrown. To return NULL instead, use `VARIANT_GET`.
- sql: variant '[' STRING ']'
table: VARIANT.at(STRING)
description: |
- If the VARIANT is a MAP value that has an element with this key, a
VARIANT holding
- the associated value is returned. Otherwise, NULL is returned.
+ If the VARIANT is an object that has a field with this key, returns a
VARIANT holding the
+ value of the field. If the object has no such field, returns NULL. If
the VARIANT is not an
+ object, an error is thrown. To return NULL instead, use `VARIANT_GET`.
+ - sql: VARIANT_GET(variant, path[, type])
+ table: VARIANT.variantGet(path[, returnType])
+ description: |
+ Returns the value of a Variant at a path, cast to `type`. Without
`type`, the value is
+ returned as a Variant. If the value cannot be cast to `type`, an error
is thrown. To return
+ NULL instead of an error, use the `TRY_VARIANT_GET` function. See the
"Variant paths" section
+ below the function table for the path syntax.
+
+ Returns NULL if:
+
+ * `variant` or `path` is NULL,
+ * nothing is at the path, or
+ * the value at the path is a variant null and `type` is not `'VARIANT'`.
+
+ Without `type`, or with `'VARIANT'`, a variant null stays a variant
null. It is not SQL NULL,
+ so `IS NULL` is false and `JSON_STRING` returns `'null'`.
+
+ `type` is a string literal such as `'INT'` or `'ARRAY<ROW<sku STRING,
qty INT>>'`, and must
+ not be NULL. The value is cast the way `CAST(v AS type)` casts a
Variant. The result is always
+ nullable. In the Table API, `returnType` is a `DataType`, and only its
logical type is used.
+
+ ```sql
+ -- 17
Review Comment:
Done for every example with a result. The one that fails keeps "fails".
--
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]