attilapiros commented on code in PR #53458:
URL: https://github.com/apache/spark/pull/53458#discussion_r2755696258


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/Cast.scala:
##########
@@ -687,6 +698,24 @@ case class Cast(
     case LongType => buildCast[Long](_, NumberConverter.toBinary)
   }
 
+  // Binary to String cast with UTF-8 validation
+  private[this] def castBinaryToString: Any => Any = buildCast[Array[Byte]](_, 
bytes => {
+    val utf8String = UTF8String.fromBytes(bytes)
+    // Check if validation is enabled
+    if (!validateUtf8) {

Review Comment:
   nit: -I would start this with `utf8String.isValid()` check.-
   
   edit: I was thinking about this a bit more and regarding performance your 
ordering is better. 
   Please keep it as it is. 



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