Repository navigation
fix(bigquery-jdbc): preserve pre-1582 and pre-standard-time DATE/DATETIME digits - #14787
Open
keshavdandeva wants to merge 1 commit into
Open
keshavdandeva wants to merge 1 commit into
keshavdandeva wants to merge 1 commit into
Conversation
Contributor
There was a problem hiding this comment.
Code Review
This pull request improves the handling of historic temporal values (pre-1582 dates and pre-standard-time digits) in the BigQuery JDBC driver by bypassing standard java.sql limitations and using java.time types directly. It introduces GregorianCalendar-based boxing and unboxing utility methods to preserve digits accurately across timezones. The review feedback highlights critical issues where the timezone parameter is ignored during Timestamp conversions in the modern fast-paths of BigQueryTypeRegistry, and points out a bug in handling BC years when boxing LocalDateTime into a Timestamp.
This branch has not been deployed
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.
b/570669354
Summary
Historic
DATE/DATETIMEvalues were read back with shifted digits, and someTIMESTAMPlocal views were shifted the same way:DATE '0001-01-01'→0001-01-03(all JVM zones)DATE '1850-06-01'→1850-05-31(e.g. JVM in America/Los_Angeles or Asia/Kolkata)getObject(ts, LocalDateTime.class)onTIMESTAMP '0001-01-01 UTC'→0001-01-03T00:00Root cause
Civil values were converted to
java.sqlobjects withjava.timerules (proleptic calendar, local mean time) but read back withjava.sqlrules (Julian calendar before 1582, standard zone offsets). The two disagree for old dates.Fix
DATE/DATETIME→java.sql.Date/Timestampnow usesjava.sql's own calendar:Date.valueOf/Timestamp.valueOf, orGregorianCalendarfields when aCalendaris given.getStringandjava.timegetters onDATE/DATETIMEconvert from the raw value, asTIMEalready did.TIMESTAMPlocal views (LocalDateTime/LocalDate/LocalTime/getDate/getTime) are derived from the instant usingjava.time.TIMESTAMPinstant semantics are unchanged, and modern dates behave as before.Known limitations
java.sql.Date/Timestampcannot represent year 0 or 1582-10-05..14.getStringand thejava.timegetters return the correct value for these.Tests
BigQueryTemporalUtilityTest,BigQueryTypeRegistryTest: historic values across JVM zones.ITTimestampTimeZoneTest: year 1, 1582 gap day and 1850 values forDATE/DATETIME/TIMESTAMP, with and withoutCalendar, in 4 JVM zones.