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/01/11 14:50:50 UTC
[GitHub] [spark] cloud-fan commented on a change in pull request #35130: [SPARK-37839][SQL] DS V2 supports partial aggregate push-down `AVG`
cloud-fan commented on a change in pull request #35130:
URL: https://github.com/apache/spark/pull/35130#discussion_r782221165
##########
File path: sql/core/src/main/scala/org/apache/spark/sql/jdbc/JdbcDialects.scala
##########
@@ -220,10 +222,16 @@ abstract class JdbcDialect extends Serializable with Logging{
Some(s"SUM($distinct$column)")
case _: CountStar =>
Some("COUNT(*)")
- case f: GeneralAggregateFunc if f.name() == "AVG" =>
- assert(f.inputs().length == 1)
- val distinct = if (f.isDistinct) "DISTINCT " else ""
- Some(s"AVG($distinct${f.inputs().head})")
+ case avg: Avg =>
+ if (avg.column.fieldNames.length != 1) return None
+ val distinct = if (avg.isDistinct) "DISTINCT " else ""
+ val column = quoteIdentifier(avg.column.fieldNames.head)
+ if (supportCompletePushDown) {
+ Some(s"AVG($distinct$column)")
+ } else {
+ // For simplify code, we not reuse exists `SUM` or `COUNT`.
+ Some(s"SUM($distinct$column), COUNT($distinct$column)")
Review comment:
It's super weird to see this translation at the data source side, not the Spark side.
--
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