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/30 11:09:05 UTC

[GitHub] [spark] cloud-fan commented on a change in pull request #35320: [SPARK-37839][SQL][FOLLOWUP] Check overflow when DS V2 partial aggregate push-down `AVG`

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



##########
File path: sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/v2/V2ScanRelationPushDown.scala
##########
@@ -132,14 +133,18 @@ object V2ScanRelationPushDown extends Rule[LogicalPlan] with PredicateHelper {
                         val count = aggregate.Count(avg.child).toAggregateExpression(isDistinct)
                         // Closely follow `Average.evaluateExpression`
                         avg.dataType match {
+                          case dt: DecimalType =>
+                            addCastIfNeeded(DecimalPrecision.decimalAndDecimal()(
+                              Divide(
+                                CheckOverflowInSum(sum, dt, !avg.failOnError),

Review comment:
       Since we need to push down SUM, we can only do it if ansi mode is true, otherwise the JDBC database may throw error for sum overflow and change the behavior of Spark AVG.




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