beliefer commented on code in PR #50101: URL: https://github.com/apache/spark/pull/50101#discussion_r1974717419
########## sql/core/src/main/scala/org/apache/spark/sql/jdbc/PostgresDialect.scala: ########## @@ -303,12 +303,24 @@ private case class PostgresDialect() class PostgresSQLBuilder extends JDBCSQLBuilder { override def visitExtract(field: String, source: String): String = { - field match { - case "DAY_OF_YEAR" => s"EXTRACT(DOY FROM $source)" - case "YEAR_OF_WEEK" => s"EXTRACT(YEAR FROM $source)" - case "DAY_OF_WEEK" => s"EXTRACT(DOW FROM $source)" - case _ => super.visitExtract(field, source) + // SECOND, MINUTE, HOUR, DAY, MONTH, QUARTER, YEAR are identical on postgres and spark for + // both datetime and interval types. + // DAY_OF_WEEK is DOW, day of week is full compatible with postgres, + // but in V2ExpressionBuilder they converted DAY_OF_WEEK to DAY_OF_WEEK_ISO, + // so we need to push down ISODOW + // (ISO and standard day of weeks differs in starting day, + // Sunday is 0 on standard DOW extraction, while in ISO it's 7) Review Comment: Got it. Thank you for the explanation. -- 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