maropu commented on a change in pull request #31052:
URL: https://github.com/apache/spark/pull/31052#discussion_r553681091
##########
File path:
sql/catalyst/src/main/scala/org/apache/spark/sql/QueryExecutionErrors.scala
##########
@@ -51,18 +58,209 @@ object QueryExecutionErrors {
s"[BUG] logical plan should not have output of char/varchar type: $leaf")
}
- def cannotEvaluateGeneratorError(generator: UnresolvedGenerator): Throwable
= {
- new UnsupportedOperationException(s"Cannot evaluate expression:
$generator")
+ def cannotEvaluateExpressionError(expression: Expression): Throwable = {
+ new UnsupportedOperationException(s"Cannot evaluate expression:
$expression")
}
- def cannotGenerateCodeForGeneratorError(generator: UnresolvedGenerator):
Throwable = {
- new UnsupportedOperationException(s"Cannot generate code for expression:
$generator")
+ def cannotGenerateCodeForExpressionError(expression: Expression): Throwable
= {
+ new UnsupportedOperationException(s"Cannot generate code for expression:
$expression")
}
def cannotTerminateGeneratorError(generator: UnresolvedGenerator): Throwable
= {
new UnsupportedOperationException(s"Cannot terminate expression:
$generator")
}
+ def castDownLongCauseOverflowError(t: Any, targetType: String): Throwable = {
+ new ArithmeticException(s"Casting $t to $targetType causes overflow")
+ }
+
+ def cannotRepresentDecimalError(value: Decimal, decimalType: DecimalType):
Throwable = {
+ new ArithmeticException(s"${value.toDebugString} cannot be represented as
" +
+ s"Decimal(${decimalType.precision}, ${decimalType.scale}).")
Review comment:
It seems `Decimal` has the same error handling, so how about sharing it
between here and `Decimal` just like this?
```
object Decimal {
def some_name(...) {...}
}
def cannotRepresentDecimalError(value: Decimal, decimalType: DecimalType):
Throwable = {
Decimal.some_name(value, decimalType)
}
```
https://github.com/apache/spark/blob/8e11ce5378a2cf69ec87501e86f7ed5963649cbf/sql/catalyst/src/main/scala/org/apache/spark/sql/types/Decimal.scala#L368-L369
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]