abir123rajbongshi-debug opened a new pull request, #60609: URL: https://github.com/apache/spark/pull/60609
### What changes were proposed in this pull request? Adds a JDBC read option, `timestampCalendarTimeZone`, naming the time zone the source renders `TIMESTAMP` values in. When it is set, `TimestampType` columns are read with `ResultSet.getTimestamp(i, calendar)` using a calendar in that zone, through a new `JDBCValueGetter.TimestampWithCalendarGetter`. When it is not set, reads use the existing `TimestampGetter` (`getTimestamp(i)`), so nothing changes. An invalid zone ID fails when the options are parsed. ### Why are the changes needed? `TimestampType` is read with `getTimestamp(i)` and no calendar. Drivers that receive timestamp text without an offset then parse it in the JVM default time zone. If the database session renders timestamps in a different zone than the Spark JVM's, every value is shifted by the difference. For example, MySQL renders `TIMESTAMP` values in the session `time_zone` with no offset. With the session at `+00:00` and a JVM in `Asia/Kolkata`, MariaDB Connector/J returns values 5h30m off. The driver's own time zone settings (`useLegacyDatetimeCode=false&serverTimezone=UTC`) also change how DATETIME values are returned by `getString`, so they cannot be used to fix only `TIMESTAMP`. A Spark-level calendar affects only `getTimestamp`, so it fixes `TimestampType` without touching other types. This is the `TimestampType` counterpart of `timestampNTZAsWallClock`. ### Does this PR introduce _any_ user-facing change? Yes. A new optional JDBC read option `timestampCalendarTimeZone` (a time zone ID such as `UTC`). It is not set by default, and existing reads behave exactly as before. Documented in `docs/sql-data-sources-jdbc.md`. ### How was this patch tested? New test in `JDBCSuite` (H2): reads a `TIMESTAMP` with `timestampCalendarTimeZone` set to `UTC` and to `Asia/Kolkata` under every JVM default zone in `DateTimeTestUtils.outstandingZoneIds`, and asserts the resulting instant is the stored wall clock in the given zone, independent of the JVM zone. It also asserts an invalid zone ID fails. The same change and test pass in Databricks Runtime CI. ### Was this patch authored or co-authored using generative AI tooling? Generated-by: Isaac (Claude Code) This pull request and its description were written by Isaac. -- 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]
