Skip to content

feat(bigquery-jdbc): add picosecond precision support for TIMESTAMP - #14038

Open
keshavdandeva wants to merge 2 commits into
jdbc/timestamp-normalizationfrom
jdbc/picosecond-precision
Open

feat(bigquery-jdbc): add picosecond precision support for TIMESTAMP#14038
keshavdandeva wants to merge 2 commits into
jdbc/timestamp-normalizationfrom
jdbc/picosecond-precision

Conversation

@keshavdandeva

@keshavdandeva keshavdandeva commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

b/544839231

This PR introduces support for picosecond precision (up to 12 fractional digits) when reading BigQuery TIMESTAMP columns, building on top of #14037

Overview

To maintain strict backwards compatibility, picosecond precision is disabled by default and activated via the new EnableTimestampPicos connection property:

  • Disabled (default): Timestamps maintain standard 6-digit microsecond precision across metadata (displaySize=26, precision=26, scale=6), getString(), getTimestamp(), and getObject().
  • Enabled on picosecond columns: Reports displaySize=32, precision=32, scale=12 in ResultSetMetaData and preserves full 12-digit picosecond precision in getString().

Changes Made

  • Configuration:

    • Added the EnableTimestampPicos connection property in BigQueryConnection and DataSource.
  • Arrow Storage Engine:

    • Configured ReadSession creation in BigQueryStatement to explicitly request TIMESTAMP_PRECISION_PICOS when EnableTimestampPicos is active.
    • Added type coercions for Text -> Timestamp and String -> Timestamp in BigQueryTypeCoercionUtility using BigQueryTemporalUtility::boxTimestamp so getObject() and getTimestamp() seamlessly handle Arrow picosecond VarCharVector columns.
  • JDBC Metadata:

    • Updated BigQueryResultSetMetadata to report displaySize=32, precision=32, and scale=12 when EnableTimestampPicos is active and the column schema precision is 12.
  • Temporal Utilities & API Safety:

    • boxTimestamp(): Gracefully down-casts 12-digit picosecond strings to 9 digits (nanoseconds) for java.sql.Timestamp, which maxes out at nanosecond precision and would otherwise throw a DateTimeParseException.
    • formatTimestampStringFromIso(): Standardized ISO-8601 formatting supporting both 'T'/'Z', SQL space-delimited (' '/' UTC'), and raw strings.

Testing

  • Unit Tests:
    • Added mocked Arrow vector tests in BigQueryArrowResultSetTest verifying getString(), getTimestamp(), and getObject() against picosecond Text columns.
    • Added metadata tests in BigQueryResultSetMetadataTest verifying precision, scale, and display size with picoseconds enabled and disabled.
    • Added ISO-8601 coercions tests in ArrowFormatTypeBigQueryCoercionUtilityTest and BigQueryTemporalUtilityTest.

@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 support for 12-digit picosecond precision for TIMESTAMP columns in the BigQuery JDBC driver, controlled by a new connection property EnableTimestampPicos. It updates result set implementations, connection settings, statement processing, and metadata to handle picosecond precision when enabled. One high-severity issue was identified where the default value for the EnableTimestampPicos property is set to the string "false" instead of "0", which could cause parsing errors during connection initialization.

@keshavdandeva
keshavdandeva marked this pull request as ready for review August 11, 2026 14:38
@keshavdandeva
keshavdandeva requested review from a team as code owners August 11, 2026 14:38
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