You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2022/03/16 14:59:08 UTC

[GitHub] [spark] cloud-fan commented on a change in pull request #35848: [SPARK-38548][SQL] New SQL function: try_sum

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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org