Skip to content

feat(bigquery-jdbc): support picosecond in REST JSON path and nested types - #14334

Open
keshavdandeva wants to merge 1 commit into
jdbc-picosecond-support-3from
jdbc-picosecond-support-4
Open

feat(bigquery-jdbc): support picosecond in REST JSON path and nested types#14334
keshavdandeva wants to merge 1 commit into
jdbc-picosecond-support-3from
jdbc-picosecond-support-4

Conversation

@keshavdandeva

Copy link
Copy Markdown
Contributor

b/503296051

This PR extends picosecond timestamp precision (TIMESTAMP(12)) support to the REST JSON query execution path and nested BigQuery data structures (ARRAY, STRUCT, RANGE).

Key Changes

  1. Centralized Schema Precision Helper:

    • Added BigQueryTemporalUtility.isPicosecondTimestamp(Field) as the single source of truth for scale > 6 timestamp fields.
    • Delegated BigQueryArrowResultSet.isPicosecondTimestamp directly to this utility.
  2. REST JSON Result Set (BigQueryJsonResultSet):

    • Eagerly binds enableTimestampPicos from the parent BigQueryStatement.
    • Formats picosecond timestamp primitives into canonical 12-decimal UTC strings (YYYY-MM-DD HH:MM:SS.SSSSSSSSSSSS).
    • Added shared formatRangeTimestamp(FieldValue) helper for RANGE<TIMESTAMP> picosecond formatting, while preserving existing BigQueryTypeRegistry fallthrough for non-pico queries.
    • Flattened getObject(int) control flow using early returns and removed redundant defensive index logic.
  3. Nested Structures (BigQueryJsonArray, BigQueryJsonStruct):

    • Propagated enableTimestampPicos across constructors and nested factories.
    • Overrode BigQueryJsonArray.getTargetClass() to return String.class when picoseconds are enabled, preventing Array.newInstance type mismatch crashes.
    • Formatted nested picosecond timestamps and timestamp ranges in getCoercedValue() and getValue().
  4. Testing & Verification:

    • Added comprehensive test coverage across BigQueryJsonResultSetTest, BigQueryJsonArrayOfPrimitivesTest, and BigQueryJsonStructTest.
    • Verified backward compatibility when enableTimestampPicos=false.

@keshavdandeva
keshavdandeva added this pull request to stack #14335 September 9, 2026 17:52
@keshavdandeva
keshavdandeva force-pushed the jdbc-picosecond-support-4 branch from 6f586bd to 303b4aa Compare September 9, 2026 17:53

@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 picosecond timestamp precision and range timestamps within the BigQuery JDBC JSON result sets, arrays, and structs. It adds an "enableTimestampPicos" flag across "BigQueryJsonArray", "BigQueryJsonResultSet", and "BigQueryJsonStruct" to conditionally format timestamps with picosecond precision or format range timestamps when enabled. Helper methods for identifying and formatting these types have been consolidated in "BigQueryTemporalUtility" and "BigQueryJsonResultSet". Comprehensive unit tests have also been added to verify the behavior of these components with the flag both enabled and disabled. I have no feedback to provide.

@keshavdandeva
keshavdandeva marked this pull request as ready for review September 9, 2026 18:02
@keshavdandeva
keshavdandeva requested review from a team as code owners September 9, 2026 18:02
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