[SPARK-58876][SQL] Map Oracle DATE and TIMESTAMP to TimestampNTZType - #58203
Open
aleksandar-trajkovic-db wants to merge 2 commits into
Open
[SPARK-58876][SQL] Map Oracle DATE and TIMESTAMP to TimestampNTZType#58203aleksandar-trajkovic-db wants to merge 2 commits into
aleksandar-trajkovic-db wants to merge 2 commits into
Conversation
Oracle DATE and TIMESTAMP are zoneless wall-clock types, so read them as TimestampNTZType by default, independent of the preferTimestampNTZ read option. Oracle DATE follows this only when the driver default oracle.jdbc.mapDateToTimestamp surfaces it as TIMESTAMP; TIMESTAMP WITH [LOCAL] TIME ZONE stay TimestampType. The new spark.sql.legacy.oracle.timestampNTZMapping.enabled flag restores the pre-4.4 behavior. Co-authored-by: Isaac
uros-b
reviewed
Aug 21, 2026
| .booleanConf | ||
| .createWithDefault(false) | ||
|
|
||
| val LEGACY_ORACLE_TIMESTAMP_NTZ_MAPPING_ENABLED = |
Member
There was a problem hiding this comment.
Please add withBindingPolicy @aleksandar-trajkovic-db
…onfig Fixes SparkConfigBindingPolicySuite (the failing CI check) and addresses the review comment: new configs must declare a binding policy. Co-authored-by: Isaac
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes were proposed in this pull request?
The Oracle JDBC dialect maps Oracle
DATEandTIMESTAMPtoTimestampNTZTypeby default, independent of thepreferTimestampNTZread option (DATEonly when the driver defaultoracle.jdbc.mapDateToTimestamp=truesurfaces it asTIMESTAMP; otherwise it staysDateType).TIMESTAMP WITH TIME ZONEandTIMESTAMP WITH LOCAL TIME ZONEare unchanged (TimestampType). A newspark.sql.legacy.oracle.timestampNTZMapping.enabled(defaultfalse) restores the prior behavior. The change also addsconvertJavaTimestampToTimestampNTZ/convertTimestampNTZToJavaTimestampoverrides (mirroringPostgresDialect) and acompileValueLocalDateTimecase so NTZ filter literals push down as JDBC{ts ...}escapes.Why are the changes needed?
Oracle
DATEandTIMESTAMPare zoneless wall-clock types. Reading them asTimestampType(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 Typerepresents these zoneless types faithfully and zone-invariantly.Does this PR introduce any user-facing change?
Yes. Oracle
TIMESTAMP(andDATEunder the driver defaultoracle.jdbc.mapDateToTimestamp=true) now reads asTimestampNTZTypeinstead ofTimestampType. Setspark.sql.legacy.oracle.timestampNTZMapping.enabled=trueto 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,compileValueliteral, and that the mapping stays microsecondTimestampNTZTypeunder the nanosecond-timestamp preview) and new/updatedOracleIntegrationSuitedocker tests (NTZ read, invariance to JVM/session/Oracle/driver time zones, WHERE pushdown, write round-trip, andmapDateToTimestampbehavior). 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.