aleksandar-trajkovic-db opened a new pull request, #58203:
URL: https://github.com/apache/spark/pull/58203

   ### What changes were proposed in this pull request?
   
   The Oracle JDBC dialect maps Oracle `DATE` and `TIMESTAMP` to 
`TimestampNTZType` by default, independent of the `preferTimestampNTZ` read 
option (`DATE` only when the driver default 
`oracle.jdbc.mapDateToTimestamp=true` surfaces it as `TIMESTAMP`; otherwise it 
stays `DateType`). `TIMESTAMP WITH TIME ZONE` and `TIMESTAMP WITH LOCAL TIME 
ZONE` are unchanged (`TimestampType`). A new 
`spark.sql.legacy.oracle.timestampNTZMapping.enabled` (default `false`) 
restores the prior behavior. The change also adds 
`convertJavaTimestampToTimestampNTZ` / `convertTimestampNTZToJavaTimestamp` 
overrides (mirroring `PostgresDialect`) and a `compileValue` `LocalDateTime` 
case so NTZ filter literals push down as JDBC `{ts ...}` escapes.
   
   ### Why are the changes needed?
   
   Oracle `DATE` and `TIMESTAMP` are zoneless wall-clock types. Reading them as 
`TimestampType` (an instant) rebases the value through the session time zone, 
so the same stored value reads back differently depending on the reader's zone. 
`TimestampNTZ
   Type` represents these zoneless types faithfully and zone-invariantly.
   
   ### Does this PR introduce _any_ user-facing change?
   
   Yes. Oracle `TIMESTAMP` (and `DATE` under the driver default 
`oracle.jdbc.mapDateToTimestamp=true`) now reads as `TimestampNTZType` instead 
of `TimestampType`. Set 
`spark.sql.legacy.oracle.timestampNTZMapping.enabled=true` to restore the 
previous behavior. Documented in the SQL migration guide.
   
   ### How was this patch tested?
   
   New unit tests in `JDBCSuite` (type mapping, zone-invariance of the 
conversion, `compileValue` literal, and that the mapping stays microsecond 
`TimestampNTZType` under the nanosecond-timestamp preview) and new/updated 
`OracleIntegrationSuite` docker tests (NTZ read, invariance to 
JVM/session/Oracle/driver time zones, WHERE pushdown, write round-trip, and 
`mapDateToTimestamp` behavior). The full Oracle integration suite passes.
   
   ### Was this patch authored or co-authored using generative AI tooling?
   Generated-by: Claude Code (Anthropic Claude Opus 4.8)
   
   This is my original work and I license it to the project under the project's 
open source license.


-- 
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]

Reply via email to