Repository navigation
fix(bigquery-jdbc): preserve civil digits for DATETIME/DATE - #14910
Open
keshavdandeva wants to merge 1 commit into
Open
keshavdandeva wants to merge 1 commit into
keshavdandeva wants to merge 1 commit into
Conversation
…te, Time, Array, and Struct accessors
Contributor
There was a problem hiding this comment.
Code Review
This pull request refactors the handling of civil temporal types (DATE, TIME, and DATETIME) in the BigQuery JDBC driver to prevent timezone conversion issues, particularly during Daylight Saving Time (DST) gaps. It introduces utility methods in BigQueryTemporalUtility to format civil temporal elements for complex types like arrays and structs without boxing them through java.sql types, and simplifies retrieval logic in BigQueryBaseResultSet and BigQueryTypeRegistry. The review feedback highlights a critical issue in the new unit test testDatetimeReadCoercionsPreserveCivilDigits where the JVM-wide default timezone is modified without being restored, which could lead to test pollution and flaky tests.
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/577457022
Summary
Prevents JVM default timezone DST gaps and historical calendar shifts from corrupting timezone-less civil temporal types (
DATETIME,DATE,TIME) when accessed asjava.sql.Date,java.sql.Time, or formatted insideARRAYandSTRUCT.Root Cause
Date/Timeextraction fromDATETIME:BigQueryBaseResultSet(getDate,getTime,getObject(int, Class)) andBigQueryTypeRegistry(createDatetimeDescriptor) boxedDATETIMEvalues into an intermediatejava.sql.Timestampin the JVM default timezone before extractingDateorTime. When aDATETIMEvalue fell inside a local DST spring-forward gap (e.g.,2025-03-09 02:30:00inAmerica/New_York), the intermediateTimestampshifted the wall-clock hour forward by +1 hour (03:30:00).ARRAY/STRUCTstring formatting:BigQueryBaseArray.toString()andBigQueryBaseStruct.appendJsonValue()called.toString()on boxedjava.sql.Timestamp/java.sql.Dateelements, corruptingARRAY<DATETIME>/STRUCT<DATETIME>values in DST gaps andARRAY<DATE>/STRUCT<DATE>values prior to the 1582 Julian–Gregorian cutover.Changes
BigQueryTemporalUtility: AddedisCivilTemporalTypeandformatCivilTemporalElementto centralize civil type checks and format rawDATE,TIME, andDATETIMEelements directly from their unshifted civil representation.BigQueryTypeRegistry: UnifiedcreateDatetimeDescriptorto parseDATETIMEintoLocalDateTimeonce and project directly toDate,Time,LocalDate,LocalTime,LocalDateTime,String, or instant views without intermediateTimestampboxing.BigQueryBaseResultSet: UpdatedgetObject,getDate,getTime, andgetTimestampto pass raw unboxed values for civil temporal types (DATE,TIME,DATETIME) toBigQueryTypeRegistry.BigQueryBaseArray&BigQueryBaseStruct: Updated string/JSON formatting to format civil temporal elements directly from raw values viaBigQueryTemporalUtility.formatCivilTemporalElement.