cloud-fan commented on a change in pull request #35848:
URL: https://github.com/apache/spark/pull/35848#discussion_r828097512



##########
File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/aggregate/Sum.scala
##########
@@ -110,9 +95,10 @@ case class Sum(
         // in case the input is nullable. The `sum` can only be null if there 
is no value, as
         // non-decimal type can produce overflowed value under non-ansi mode.
         if (child.nullable) {

Review comment:
       I have a different and simpler idea to do abstraction
   ```
   protected def createAddExpr(left: Expression, right: Expression): Expression 
= {
     Add(left, right, failOnError)
   }
   ```
   and here we can do
   ```
   Seq(coalesce(
     createAddExpr(coalesce(sum, zero), child.cast(resultType)),
     sum))
   ```
   Then `TrySum` can override it
   ```
   val add = super.createAddExpr(left, right)
   if (failOnError) TryEval(add) else add
   ```




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

Reply via email to