viirya commented on code in PR #55938:
URL: https://github.com/apache/spark/pull/55938#discussion_r3261864397
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/arithmetic.scala:
##########
@@ -458,6 +449,10 @@ case class Add(
MathUtils.addExact(input1.asInstanceOf[Int], input2.asInstanceOf[Int],
getContextOrNull())
case _: LongType if failOnError =>
MathUtils.addExact(input1.asInstanceOf[Long], input2.asInstanceOf[Long],
getContextOrNull())
+ case _: ByteType if failOnError =>
+ ArithmeticUtils.byteAddExact(input1.asInstanceOf[Byte],
input2.asInstanceOf[Byte])
+ case _: ShortType if failOnError =>
+ ArithmeticUtils.shortAddExact(input1.asInstanceOf[Short],
input2.asInstanceOf[Short])
Review Comment:
Why route Add/Subtract/Multiply.nullSafeEval through the helper rather than
just leaving them as numeric.plus(...)? The pre-PR case _ => numeric.plus(...)
was concise and already correct. The new ANSI-specific branches add 8 lines × 3
expressions = 24 lines of arguably unnecessary code.
Consider dropping the eval-side branches (Add/Subtract/Multiply.nullSafeEval
byte/short cases). They're redundant with the existing
numeric.plus-via-ByteExactNumeric route.
--
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]