panbingkun commented on code in PR #48653:
URL: https://github.com/apache/spark/pull/48653#discussion_r1837600750


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/csv/UnivocityParser.scala:
##########
@@ -179,16 +185,16 @@ class UnivocityParser(
       dataType: DataType,
       nullable: Boolean = true): ValueConverter = dataType match {
     case _: ByteType => (d: String) =>
-      nullSafeDatum(d, name, nullable, options)(_.toByte)
+      nullSafeDatum(d, name, nullable, options)(retryWithTrim[Byte](_.toByte))

Review Comment:
   I even suspect it's a problem with JDK itself, haha
     
   A.Int: java.lang.Integer.parseInt(...)
     ```
     scala> val x = java.lang.Integer.parseInt(" 1")
     java.lang.NumberFormatException: For input string: " 1"
       at 
java.base/java.lang.NumberFormatException.forInputString(NumberFormatException.java:67)
       at java.base/java.lang.Integer.parseInt(Integer.java:654)
       at java.base/java.lang.Integer.parseInt(Integer.java:786)
       ... 41 elided
     ```
   
     B.Double: java.lang.Double.parseDouble(...)
     ```scala
     scala> val x = java.lang.Double.parseDouble(" 1")
     val x: Double = 1.0
     ```
   
     ```java
     public static double parseDouble(String s) throws NumberFormatException {
       return FloatingDecimal.parseDouble(s);
     }
     ```
   
     <img width="800" alt="image" 
src="https://github.com/user-attachments/assets/406ca81f-2d11-4a1a-9f42-bd8e5ffab03f";>



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