cloud-fan commented on code in PR #36663:
URL: https://github.com/apache/spark/pull/36663#discussion_r910687319
##########
sql/core/src/main/scala/org/apache/spark/sql/jdbc/H2Dialect.scala:
##########
@@ -123,4 +127,26 @@ private[sql] object H2Dialect extends JdbcDialect {
}
super.classifyException(message, e)
}
+
+ override def compileExpression(expr: Expression): Option[String] = {
+ val jdbcSQLBuilder = new H2JDBCSQLBuilder()
+ try {
+ Some(jdbcSQLBuilder.build(expr))
+ } catch {
+ case NonFatal(e) =>
+ logWarning("Error occurs while compiling V2 expression", e)
+ None
+ }
+ }
+
+ class H2JDBCSQLBuilder extends JDBCSQLBuilder {
+
+ override def visitExtract(field: String, source: String): String = {
+ field match {
+ case "WEEK" => s"EXTRACT(ISO_WEEK FROM $source)"
+ case "YEAR_OF_WEEK" => s"EXTRACT(ISO_WEEK_YEAR FROM $source)"
Review Comment:
is it common that databases add the `ISO_` prefix to field names?
--
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]