cloud-fan commented on code in PR #48203:
URL: https://github.com/apache/spark/pull/48203#discussion_r1770907974


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/stringExpressions.scala:
##########
@@ -3039,7 +3039,7 @@ object Encode {
       legacyCharsets: Boolean,
       legacyErrorAction: Boolean): Array[Byte] = {
     val toCharset = charset.toString
-    if (input.numBytes == 0 || "UTF-8".equalsIgnoreCase(toCharset)) {
+    if (input.numBytes == 0 || ("UTF-8".equalsIgnoreCase(toCharset) && 
input.isValid)) {

Review Comment:
   another missed case is when the charset name is invalid. Previously we 
always fail even though the input bytes is empty.



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