Github user cloud-fan commented on a diff in the pull request:
https://github.com/apache/spark/pull/6405#discussion_r31199138
--- Diff:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/arithmetic.scala
---
@@ -97,88 +112,84 @@ abstract class BinaryArithmetic extends
BinaryExpression {
}
}
- def evalInternal(evalE1: Any, evalE2: Any): Any =
- sys.error(s"BinaryExpressions must either override eval or
evalInternal")
+ protected def evalInternal(evalE1: Any, evalE2: Any): Any =
+ sys.error(s"BinaryArithmetics must either override eval or
evalInternal")
}
case class Add(left: Expression, right: Expression) extends
BinaryArithmetic {
override def symbol: String = "+"
- lazy val numeric = dataType match {
- case n: NumericType => n.numeric.asInstanceOf[Numeric[Any]]
- case other => sys.error(s"Type $other does not support numeric
operations")
- }
-
- override def eval(input: Row): Any = {
- val evalE1 = left.eval(input)
- if(evalE1 == null) {
- null
- } else {
- val evalE2 = right.eval(input)
- if (evalE2 == null) {
- null
+ protected def errorMessageInternal(t: DataType) = {
+ TypeUtils.checkForNumericExpr(t, "todo").orElse {
--- End diff --
As the [origin
code](https://github.com/apache/spark/blob/master/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/arithmetic.scala#L76)
requires not only numeric type, but also `!DecimalType.isFixed(left.dataType)`
for `Add`, `Subtract`, etc.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]