Skip to content

fix(bigquery-jdbc): request int64 timestamps so the REST path is lossless - #14890

Open
keshavdandeva wants to merge 3 commits into
mainfrom
fix/jdbc-iso-timestamp-format
Open

keshavdandeva wants to merge 3 commits into
mainfrom
fix/jdbc-iso-timestamp-format

Conversation

@keshavdandeva

Copy link
Copy Markdown
Contributor

b/577457377

Summary

On the REST path, BigQuery returns TIMESTAMP values as float64 seconds by default. That loses microseconds for dates far from 1970, and 9999-12-31 23:59:59.999999 UTC comes back as year 10000. The value is rounded by the server, so the driver can't fix it on the client.

Fix

  • Connections now request useInt64Timestamp(true), which returns exact epoch microseconds. With EnableTimestampPicos=1 we still request ISO8601_STRING, because BigQuery rejects both together.
  • The REST path now reads int64 TIMESTAMP values as epoch micros, as the Arrow path already does. This covers top-level, STRUCT/ARRAY and RANGE values.

Tests

  • BigQueryConnectionTest: default connections request int64 timestamps.
  • BigQueryJsonResultSetTest: int64 TIMESTAMP and RANGE<TIMESTAMP> values decode exactly.
  • ITTimestampTimeZoneTest: adds 9999-12-31 23:59:59.999999 UTC to the existing getTimestamp / getString checks across 4 JVM zones. These checks fail without the fix (+10000-01-01) and pass with it.

@keshavdandeva
keshavdandeva requested review from a team as code owners November 2, 2026 16:14

@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 implements support for lossless int64-encoded timestamps when picosecond precision is disabled. It configures DataFormatOptions to request int64 timestamps by default, preserves FieldValue wrappers for TIMESTAMP columns to identify these encoded values, and decodes them to epoch microseconds during type conversion and range formatting. The review feedback suggests improving the robustness of the range bound parsing in BigQueryTemporalUtility by wrapping the Long.valueOf conversions in a try-catch block to handle potential NumberFormatExceptions and throw a BigQueryJdbcException.

This branch has not been deployed

No deployments
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.

1 participant