qlong commented on code in PR #53458:
URL: https://github.com/apache/spark/pull/53458#discussion_r2795543877
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/Cast.scala:
##########
@@ -1380,7 +1414,41 @@ case class Cast(
val fromArg = ctx.addReferenceObj("from", from)
(c, evPrim, evNull) => code"$evPrim = $cls.castToVariant($c, $fromArg);"
case s: StringType =>
- (c, evPrim, _) => castToStringCode(from, ctx, s.constraint).apply(c,
evPrim)
+ // BinaryType to StringType cast with UTF-8 validation
+ from match {
+ case BinaryType =>
+ val tmp = ctx.freshVariable("tmp", classOf[UTF8String])
+
+ if (!validateUtf8) {
+ // Old behavior: no validation
+ (c, evPrim, evNull) =>
+ code"$evPrim = UTF8String.fromBytes($c);"
Review Comment:
missed the conversation for char/varchar. Added support and test cases.
--
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]