cloud-fan commented on code in PR #36698:
URL: https://github.com/apache/spark/pull/36698#discussion_r884783483
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/aggregate/Average.scala:
##########
@@ -75,18 +80,17 @@ abstract class AverageBase
)
protected def getMergeExpressions = Seq(
- /* sum = */ Add(sum.left, sum.right, useAnsiAdd),
+ /* sum = */ add(sum.left, sum.right),
/* count = */ count.left + count.right
)
// If all input are nulls, count will be 0 and we will get null after the
division.
// We can't directly use `/` as it throws an exception under ansi mode.
protected def getEvaluateExpression(queryContext: String) = child.dataType
match {
case _: DecimalType =>
- DecimalPrecision.decimalAndDecimal()(
- Divide(
- CheckOverflowInSum(sum, sumDataType.asInstanceOf[DecimalType],
!useAnsiAdd, queryContext),
- count.cast(DecimalType.LongDecimal), failOnError =
false)).cast(resultType)
+ Divide(
Review Comment:
The intention was to check overflow on the division result, which was not
possible before. Now if we can have a `DecimalDivide`, we can remove
`CheckOverflowInSum` as well.
--
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]