anchovYu commented on code in PR #36241:
URL: https://github.com/apache/spark/pull/36241#discussion_r851881447


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/util/UTF8StringUtils.scala:
##########
@@ -26,23 +27,23 @@ import org.apache.spark.unsafe.types.UTF8String
 object UTF8StringUtils {
 
   def toLongExact(s: UTF8String, errorContext: String): Long =
-    withException(s.toLongExact, errorContext)
+    withException(s.toLongExact, errorContext, LongType, s)
 
   def toIntExact(s: UTF8String, errorContext: String): Int =
-    withException(s.toIntExact, errorContext)
+    withException(s.toIntExact, errorContext, IntegerType, s)
 
   def toShortExact(s: UTF8String, errorContext: String): Short =
-    withException(s.toShortExact, errorContext)
+    withException(s.toShortExact, errorContext, ShortType, s)
 
   def toByteExact(s: UTF8String, errorContext: String): Byte =
-    withException(s.toByteExact, errorContext)
+    withException(s.toByteExact, errorContext, ByteType, s)
 
-  private def withException[A](f: => A, errorContext: String): A = {
+  private def withException[A](f: => A, errorContext: String, to: DataType, s: 
UTF8String): A = {
     try {
       f
     } catch {
       case e: NumberFormatException =>
-        throw QueryExecutionErrors.invalidInputSyntaxForNumericError(e, 
errorContext)
+        throw QueryExecutionErrors.invalidInputSyntaxForNumericError(to, s, 
errorContext)

Review Comment:
   But the side effect is, it throws the 
`org.apache.spark.SparkNumberFormatException` instead of the 
`java.lang.NumberFormatException`. The former is a subclass of the latter, so 
the code catching the latter will still work with the updated version. Will it 
be a problem? 



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