zhangfengcdt commented on code in PR #2073:
URL: https://github.com/apache/sedona/pull/2073#discussion_r2193650666


##########
spark/common/src/main/scala/org/apache/sedona/python/wrapper/utils/implicits.scala:
##########
@@ -50,10 +50,13 @@ object implicits {
 
     def userDataToUtf8ByteArray: Array[Byte] = {
       geometry.getUserData match {
+        // Case when user data is null: return an empty UTF-8 byte array
         case null => EMPTY_STRING.getBytes(StandardCharsets.UTF_8)
+        // Case when user data is a String: convert the string to a UTF-8 byte 
array
         case data: String => data.getBytes(StandardCharsets.UTF_8)
+        // Case for any other type: convert to string, then to a UTF-8 byte 
array
+        case data => data.toString.getBytes(StandardCharsets.UTF_8)

Review Comment:
   The issue is that we cannot directly convert a generic Object (data) to 
bytes using getBytes(StandardCharsets.UTF_8) unless the object is a String or 
implements such a method. The issue here is caused by UnsafeRow object, so I am 
adding that specifically but keep the rest (unknown types) cast to string and 
getBytes.
   



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

Reply via email to