raminqaf commented on code in PR #29092:
URL: https://github.com/apache/flink/pull/29092#discussion_r3943661252


##########
docs/content.zh/docs/sql/reference/data-types.md:
##########
@@ -1614,6 +1614,33 @@ CAST(m AS ARRAY<STRING>)   -- ['1', 'a'], a 
heterogeneous array still renders ea
 CAST(m AS ARRAY<VARIANT>)  -- [1, "a"] as variants, one level shredded
 ```
 
+A variant object casts to `ROW` or `STRUCTURED`, which likewise imposes a 
schema on it. The variant
+must be an object, otherwise the cast fails. Each field is itself a `VARIANT`, 
so it casts to its
+declared type by the same rules, recursively. Fields match by name rather than 
by position, since a
+JSON object is unordered, and name matching is case sensitive. A `ROW` 
declared without field names
+uses the default names `f0`, `f1`, and so on, which must then be present in 
the object.
+
+- A field absent from the object fails the cast, whether the target field is 
nullable or not.
+- A field present but set to a variant null maps to SQL `NULL` when the field 
is nullable and fails
+  the cast when it is `NOT NULL`.
+- Object fields the target does not name are dropped, so the row is a 
projection.
+- A `ROW` or `STRUCTURED` whose fields are `VARIANT` is the identity on those 
fields: it shreds one
+  level and keeps the rest semi-structured. A field set to a variant null 
stays a variant null
+  rather than becoming SQL `NULL`.
+
+If any field cast fails, the whole cast fails, and `TRY_CAST` returns `NULL` 
for the entire value
+rather than a partial result, exactly as for an array target.

Review Comment:
   removed



-- 
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]

Reply via email to