Repository navigation
Conversation
Contributor
There was a problem hiding this comment.
Code Review
This pull request refactors temporal parameter handling in the BigQuery JDBC driver to ensure timezone-independent formatting. It formats TIMESTAMP parameters in UTC with a trailing 'Z' and binds LocalDateTime as a STRING to prevent breaking changes, supported by comprehensive unit and integration tests. The review feedback highlights a critical improvement to specify Locale.ROOT when creating DateTimeFormatter instances to prevent formatting issues in environments with non-Gregorian default locales. Additionally, it suggests formatting java.util.Date using the UTC instant formatter to avoid malformed string fallbacks.
Neenu1995
marked this pull request as draft
October 13, 2026 17:35
Neenu1995
marked this pull request as ready for review
October 13, 2026 18:10
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.
Fixes b/565785268 (
setTimestampdrops the offset), b/565786188 (setObject(Instant / OffsetDateTime / ZonedDateTime)discards the zone), b/566151602 (setObject(LocalDateTime)can't be inserted into
DATETIME).Root cause
TIMESTAMPparameters were rendered withTimestamp.toString(): JVM-local digits, no zone label.BigQuery reads an unlabelled string as UTC, so on any non-UTC JVM the stored moment moved by the
JVM offset. Zone-aware types were collapsed to
Timestampfirst and lost their zone the same way.setObject(LocalDateTime)went throughTimestamp.valueOfand was bound as aTIMESTAMPparameter, which BigQuery refuses to insert into a
DATETIMEcolumn. It looked fine onmainonly because interpret-in-JVM-zone and print-in-JVM-zone cancelled; fixing the formatter alone
would have broken that cancellation and shifted
LocalDateTimedigits, so both land together.Fix
BigQueryParameterHandler: every instant-carrying type in aTIMESTAMPslot is reduced toits
Instantand rendered in UTC with a trailingZ. UTC (not the caller's offset) because theclient-library validator rejects
-05:00but acceptsZ.DATETIMEslots unchanged.BigQueryPreparedStatement.setTemporalObject:LocalDateTimeis bound as aSTRINGoffixed-width digits. Chosen over a typed
DATETIMEbinding to avoid a breaking change —STRINGis accepted by both
DATETIMEandTIMESTAMPcolumns.Behaviour change (JVM = America/New_York)
setTimestamp/setObject(Timestamp|Instant|OffsetDateTime|ZonedDateTime)setTimestamp(ts, cal)getTimestamp→setTimestampround tripsetObject(LocalDateTime)→ INSERT intoDATETIMETIMESTAMP)setObject(LocalDateTime)→ INSERT intoTIMESTAMPNo change to
DATE,TIME,DATETIMEformatting or any read path.Tests
identically; output passes
QueryParameterValue's validator;DATETIMEslot unchanged;LocalDateTimebinds asSTRINGwith zone-free, fixed-width digits.ITTimestampTimeZoneTest, new, 4 JVM zones): all write-path cases above, including realINSERTs into
TIMESTAMPandDATETIME. Read-path cases for b/565791346, b/563395776 andb/565818805 are included but
@Disabledfor the follow-up PR.Follow-ups
getString), b/565818888 (TIMESTAMP(12)).setTime(t, cal)direction — unmeasured here.CallableStatement.setObject(String, LocalDateTime)and the Storage Write API batch path donot go through this formatter — not changed.
DATETIMEbinding forLocalDateTimeis a deliberate behaviour change to decide separately.