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 2021/12/28 03:45:44 UTC

[GitHub] [spark] huaxingao commented on a change in pull request #35009: [SPARK-37527][SQL] Translate more standard aggregate functions for pushdown

huaxingao commented on a change in pull request #35009:
URL: https://github.com/apache/spark/pull/35009#discussion_r775712142



##########
File path: sql/core/src/main/scala/org/apache/spark/sql/jdbc/H2Dialect.scala
##########
@@ -22,11 +22,35 @@ import java.util.Locale
 
 import org.apache.spark.sql.AnalysisException
 import org.apache.spark.sql.catalyst.analysis.{NoSuchNamespaceException, NoSuchTableException, TableAlreadyExistsException}
+import org.apache.spark.sql.connector.expressions.aggregate.{AggregateFunc, Average, StddevPop, StddevSamp, VarPop, VarSamp}
 
 private object H2Dialect extends JdbcDialect {
   override def canHandle(url: String): Boolean =
     url.toLowerCase(Locale.ROOT).startsWith("jdbc:h2")
 
+  override def compileAggregate(aggFunction: AggregateFunc): Option[String] = {
+    super.compileAggregate(aggFunction).orElse(
+      aggFunction match {
+        case avg: Average =>
+          if (avg.column.fieldNames.length != 1) return None
+          Some(s"AVG(${quoteIdentifier(avg.column.fieldNames.head)})")

Review comment:
       Should we put `avg` in `super.compileAggregate(aggFunction)` since all the databases support it?




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