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