chenhao-db opened a new pull request, #45989: URL: https://github.com/apache/spark/pull/45989
### What changes were proposed in this pull request? This PR allows casting another type into the variant type. The changes can be divided into two major parts: - The `VariantBuilder` class is greatly refactored. Many of its APIs are exposed so that Spark can use them to build a variant value without JSON parsing. - The actual implementation of the cast. ### Why are the changes needed? It provides a convenient way to build variant values from other Spark values. Before this PR, `parse_json` is the only SQL function that can produce variant values. If users want to do so, they may have to use `parse_json(to_json(input))`, which is inefficient and disallowed if the input has a scalar type. ### Does this PR introduce _any_ user-facing change? Yes. Casting to variant was previously not allowed but now allowd. ### How was this patch tested? Unit tests. ### Was this patch authored or co-authored using generative AI tooling? No. -- 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]
