MaxGekk commented on code in PR #56653:
URL: https://github.com/apache/spark/pull/56653#discussion_r3459093115
##########
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/jdbc/JdbcUtils.scala:
##########
@@ -164,6 +164,7 @@ object JdbcUtils extends Logging with SQLConfHelper {
// Note that some dialects override this setting, e.g. as SQL Server.
case TimestampNTZType => Option(JdbcType("TIMESTAMP",
java.sql.Types.TIMESTAMP))
case DateType => Option(JdbcType("DATE", java.sql.Types.DATE))
+ case t: TimeType => Option(JdbcType(s"TIME(${t.precision})",
java.sql.Types.TIME))
Review Comment:
Non-blocking, for the per-dialect follow-ups: `TimeType.precision` can be up
to 9 (`MAX_PRECISION`), so this emits `TIME(7)`..`TIME(9)` for high-precision
columns — but PostgreSQL, MySQL, and SQL Server cap fractional-second precision
at 6 and reject that DDL. It fails loudly rather than silently corrupting, and
the tests use H2 (which supports `TIME(9)`), so the round-trip tests don't
surface it. Clamping to the dialect's max precision belongs naturally in the
per-dialect overrides you've scoped as follow-ups — flagging so it's tracked.
(`DecimalType`, the pattern this mirrors, never emits out-of-range DDL within
its own max of 38.)
##########
connector/docker-integration-tests/src/test/scala/org/apache/spark/sql/jdbc/PostgresIntegrationSuite.scala:
##########
@@ -186,8 +186,9 @@ class PostgresIntegrationSuite extends
SharedJDBCIntegrationSuite {
}
test("Type mapping for various types") {
- val df = spark.read.jdbc(jdbcUrl, "bar", new Properties)
- val rows = df.collect().sortBy(_.toString())
+ withSQLConf(SQLConf.TIME_TYPE_ENABLED.key -> "false") {
+ val df = spark.read.jdbc(jdbcUrl, "bar", new Properties)
+ val rows = df.collect().sortBy(_.toString())
Review Comment:
Nit: the body of this new `withSQLConf { ... }` block isn't re-indented —
`val df`/`val rows` got the extra two spaces but everything from
`assert(rows.length == 2)` down stays at the outer indent, so the block reads
as if it's outside the `withSQLConf`. Same pattern in `DB2IntegrationSuite`
("Date types") and `MySQLIntegrationSuite` ("Date types" / "SPARK-47406").
--
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]