anchovYu commented on code in PR #36241:
URL: https://github.com/apache/spark/pull/36241#discussion_r851879953
##########
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:
Here it doesn't use the error message in `e` coming from `toLongExact`, but
uses the error message in error-classes.json for better error message
organization and grouping.
--
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]