cloud-fan commented on code in PR #50112: URL: https://github.com/apache/spark/pull/50112#discussion_r2050131350
########## sql/core/src/main/scala/org/apache/spark/sql/jdbc/MySQLDialect.scala: ########## @@ -51,14 +51,19 @@ private case class MySQLDialect() extends JdbcDialect with SQLConfHelper with No supportedFunctions.contains(funcName) class MySQLSQLBuilder extends JDBCSQLBuilder { - override def visitExtract(field: String, source: String): String = { + + override def visitExtract(extract: Extract): String = { + val field = extract.field field match { - case "DAY_OF_YEAR" => s"DAYOFYEAR($source)" - case "YEAR_OF_WEEK" => s"EXTRACT(YEAR FROM $source)" + case "DAY_OF_YEAR" => s"DAYOFYEAR(${build(extract.source())})" + case "WEEK" => s"WEEKOFYEAR(${build(extract.source())})" + case "YEAR_OF_WEEK" => visitUnexpectedExpr(extract) // WEEKDAY uses Monday = 0, Tuesday = 1, ... and ISO standard is Monday = 1, ..., // so we use the formula (WEEKDAY + 1) to follow the ISO standard. - case "DAY_OF_WEEK" => s"(WEEKDAY($source) + 1)" - case _ => super.visitExtract(field, source) + case "DAY_OF_WEEK" => s"(WEEKDAY(${build(extract.source())}) + 1)" + // SECOND, MINUTE, HOUR, DAY, MONTH, QUARTER, YEAR are identical on MySQL and Spark for Review Comment: Extract second returns integer on MySQL, while spark returns decimal(8,6), so it cannot be pushed down because of loosing decimal part. -- 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-unsubscr...@spark.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org