linhongliu-db commented on PR #60582:
URL: https://github.com/apache/spark/pull/60582#issuecomment-6937010972

   On the decision challenge (which error the rejection reports): I went with 
the dedicated subclass. A cast whose source is VARIANT and whose target the 
check rejects now fails with 
`DATATYPE_MISMATCH.CAST_VARIANT_TO_NON_NULLABLE_TARGET`, in ANSI, LEGACY and 
TRY modes. The message says the target has a non-nullable struct field, or a 
non-nullable array element or map value of a type other than VARIANT, and that 
the cast returns NULL there for a missing key or a JSON null. It says to make 
that slot nullable, and names 
`spark.sql.legacy.variant.allowCastToNonNullableTarget` as the way to restore 
the old behavior. Its wording of the rule matches the corrected code comment, 
conf doc and migration note.
   
   When the VARIANT is nested inside a struct source, the cast keeps 
`CAST_WITHOUT_SUGGESTION`. There the cast can also fail for reasons unrelated 
to nullability, and the new message would then point at a conf that doesn't 
help. The `VariantSuite` assertions check both conditions and the `config` 
parameter.
   


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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to