Skip to content

fix(bigquery-jdbc): normalize setTime from Calendar zone to JVM zone - #14660

Merged
keshavdandeva merged 3 commits into
mainfrom
jdbc/fix-set-time-calendar
Oct 15, 2026
Merged

keshavdandeva merged 3 commits into
mainfrom
jdbc/fix-set-time-calendar

Conversation

@keshavdandeva

Copy link
Copy Markdown
Contributor

b/565818805

Summary

Fixes PreparedStatement.setTime(..., Calendar) and CallableStatement.setTime(..., Calendar) applying the Calendar timezone offset in the wrong direction.

Problem

BigQueryTemporalUtility.convertTimeWithCalendar(Time, Calendar) shifts wall-clock time fields from the JVM default timezone into the target Calendar's timezone (the read-side direction used by CallableStatement.getTime(..., Calendar)). Calling it in setTime(..., Calendar) shifted the offset in the opposite direction before BigQueryParameterHandler formatted the Time in the JVM default timezone.

Changes

  • Added BigQueryTemporalUtility.convertTimeToCalendar(Time, Calendar) (mirroring convertDateToCalendar) to extract local time fields in the provided Calendar's timezone and normalize them to 1970-01-01 in the JVM default timezone.
  • Updated BigQueryPreparedStatement.setTime(int, Time, Calendar) and BigQueryCallableStatement.setTime(String, Time, Calendar) to call convertTimeToCalendar.
  • Added unit tests in BigQueryTemporalUtilityTest, BigQueryPreparedStatementSettersTest, and BigQueryCallableStatementTest.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a new utility method convertTimeToCalendar in BigQueryTemporalUtility to convert and normalize java.sql.Time parameters using a target Calendar's timezone, and updates BigQueryCallableStatement and BigQueryPreparedStatement to use it. Unit tests have also been expanded to cover these cross-timezone conversions. The feedback suggests refactoring convertTimeToCalendar to use legacy Calendar manipulation instead of java.time APIs to ensure proper handling of Daylight Saving Time (DST).

@keshavdandeva
keshavdandeva marked this pull request as ready for review October 15, 2026 13:03
@keshavdandeva
keshavdandeva requested review from a team as code owners October 15, 2026 13:03
@keshavdandeva
keshavdandeva force-pushed the jdbc/fix-set-time-calendar branch from ca339b7 to 55aa784 Compare October 15, 2026 14:52
@keshavdandeva
keshavdandeva merged commit 54d2bc6 into main Oct 15, 2026
202 checks passed
@keshavdandeva
keshavdandeva deleted the jdbc/fix-set-time-calendar branch October 15, 2026 18:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants