Skip to content

feat(bigquery-jdbc): support picosecond timestamp in ResultSetMetaData and DatabaseMetaData - #14358

Open
keshavdandeva wants to merge 1 commit into
mainfrom
jdbc-picosecond-support-5
Open

feat(bigquery-jdbc): support picosecond timestamp in ResultSetMetaData and DatabaseMetaData#14358
keshavdandeva wants to merge 1 commit into
mainfrom
jdbc-picosecond-support-5

Conversation

@keshavdandeva

Copy link
Copy Markdown
Contributor

b/556665374

This PR implements metadata reflection for picosecond timestamps across ResultSetMetaData and DatabaseMetaData.getColumns() when EnableTimestampPicos is active.

Key Changes

  1. Result Set Metadata (BigQueryResultSetMetadata):

    • Reflects picosecond timestamp columns as Types.VARCHAR, type name TIMESTAMP_PICOSECONDS, String.class, display size 32, precision 32, and scale 12 when enabled.
    • Evaluates enableTimestampPicos once during initialization.
    • Aligned standard timestamp getColumnDisplaySize fallback from legacy 16 to spec-compliant 26 ("YYYY-MM-DD HH:MM:SS.ffffff").
  2. Database Metadata (BigQueryDatabaseMetaData):

    • Updated mapBigQueryTypeToJdbc to return ColumnTypeInfo(Types.VARCHAR, TIMESTAMP_PICOSECONDS, 32, 12, null) for non-repeated picosecond timestamp fields when connection.isEnableTimestampPicos() is active.
    • Ensured repeated timestamp fields continue reflecting as Types.ARRAY.
  3. Centralized Constant (BigQueryTemporalUtility):

    • Defined TIMESTAMP_PICOSECONDS_TYPE_NAME = "TIMESTAMP_PICOSECONDS" to eliminate duplicate magic string literals across metadata components.
  4. Testing & Verification:

    • Added tests in BigQueryResultSetMetadataTest and BigQueryDatabaseMetaDataTest verifying metadata reflection for enabled, disabled, repeated array, and standard timestamp columns.

@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-precision timestamps in the BigQuery JDBC driver when the feature is enabled. It updates BigQueryDatabaseMetaData and BigQueryResultSetMetadata to correctly map and describe picosecond timestamp columns as VARCHAR types with a precision of 32 and scale of 12, while returning String as the column class name. Additionally, the default display size for standard TIMESTAMP columns has been increased from 16 to 26. Extensive unit tests have been added to verify these metadata behaviors under different configurations. There are no review comments to address, so no further feedback is provided.

@keshavdandeva
keshavdandeva marked this pull request as ready for review September 11, 2026 16:39
@keshavdandeva
keshavdandeva requested review from a team as code owners September 11, 2026 16:39
this.schemaFieldList = schemaFieldList;
this.columnCount = schemaFieldList.size();
this.statement = statement;
this.enableTimestampPicos =

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.

We should be able to change constructor parameter to be BigQueryStatement. Either way we don't support any other type

return false;
}
Field field = getField(sqlColumn);
return field.getMode() != Mode.REPEATED && BigQueryTemporalUtility.isPicosecondTimestamp(field);

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.

Should we move this check to isPicosecondTimestamp()?

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