mickjermsurawong-stripe commented on a change in pull request #25033: 
[SPARK-28224][SQL] Aggregate sum large decimals
URL: https://github.com/apache/spark/pull/25033#discussion_r300536275
 
 

 ##########
 File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/aggregate/Sum.scala
 ##########
 @@ -89,5 +90,10 @@ case class Sum(child: Expression) extends 
DeclarativeAggregate with ImplicitCast
     )
   }
 
-  override lazy val evaluateExpression: Expression = sum
+  override lazy val evaluateExpression: Expression = dataType match {
+    case DecimalType.Fixed(precision, scale) =>
+      CheckOverflow(sum, DecimalType(precision, scale), 
SQLConf.get.decimalOperationsNullOnOverflow)
 
 Review comment:
   Updated to using matched case because `resultType` is still a generic 
DataType and not Decimal type
   ```
     override lazy val evaluateExpression: Expression = resultType match {
       case d: DecimalType => CheckOverflow(sum, d, 
SQLConf.get.decimalOperationsNullOnOverflow)
       case _ => sum
     }
   ```

----------------------------------------------------------------
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]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to