Skip to content
This repository was archived by the owner on Mar 5, 2026. It is now read-only.

feat: Add high precision Picosecond timestamp support for write calls#654

Merged
danieljbruce merged 32 commits into
mainfrom
picos-timestamp-feature
Feb 25, 2026
Merged

feat: Add high precision Picosecond timestamp support for write calls#654
danieljbruce merged 32 commits into
mainfrom
picos-timestamp-feature

Conversation

@danieljbruce
Copy link
Copy Markdown
Contributor

Description

For write calls with the grpc client this PR adds code changes that allow users to write rows that have high precision timestamp data. Most of the changes just require changes to the plumbing to ensure the timestamp precision property is used and the type mappings are correct when we want to preserve these high precision strings.

Impact

Allows users to write rows that have high precision timestamps.

Testing

A new system test does a write and then confirms with a read that the write worked correctly.

Additional Information

Files changed:
arrow.proto, avro.proto, storage.proto, stream.proto, table.proto, protos.d.ts, protos.js, protos.json were all added just from running a bazel command in googleapis-gen and copied over directly.

src/adapt/proto.ts: This is the code that ensures the row gets mapped to a string instead of an int so that it doesn't lose precision.

src/adapt/schema.ts: This code ensures the storage schema has the timestampPrecision: 12 data if that data is provided in the table schema so that proto.ts knows when to map row timestamp data to a string before writing.

managed_writer_client_test.ts: Added a test that does a write with the client for a row with high timestamp precision and then immediately does a read to ensure the write was done for the timestamp with high precision.

danieljbruce and others added 22 commits February 19, 2026 14:15
Modify the system test in `timestamp_output_format.ts` to use `table.request`
instead of `table.getRows`. This ensures that we are checking the raw
data returned by the server, bypassing any unreleased changes in the
BigQuery library. The test now verifies high-precision timestamps by
inspecting the raw JSON response from the `/data` endpoint.

Co-authored-by: danieljbruce <8935272+danieljbruce@users.noreply.github.com>
Added a new system test case to `managed_writer_client_test.ts` that
verifies the ability to write timestamps with picosecond precision.
The test creates a new table with a schema specifying
`timestampPrecision: 12` and writes a row with a high-precision
timestamp string.

This test helps ensure that the BigQuery Storage Write API and the
associated adaptation logic correctly handle picosecond precision
timestamps.

Co-authored-by: danieljbruce <8935272+danieljbruce@users.noreply.github.com>
@danieljbruce danieljbruce requested a review from a team as a code owner February 24, 2026 21:55
@danieljbruce danieljbruce requested a review from a team February 24, 2026 21:55
@product-auto-label product-auto-label Bot added size: xl Pull request size is extra large. api: bigquerystorage Issues related to the googleapis/nodejs-bigquery-storage API. labels Feb 24, 2026
Copy link
Copy Markdown
Contributor

@alvarowolfx alvarowolfx left a comment

Choose a reason for hiding this comment

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

Just some nits

options['formatOptions.timestampOutputFormat'] = timestampOutputFormat;
options['formatOptions.useInt64Timestamp'] = useInt64Timestamp;

await new Promise<void>((resolve, reject) => {
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.

add a TODO to use the latest of nodejs-bigquery once picosecond support arrives there. Felt odd to see usage of .request here, but then I figure out was due to support to picosecond not here yet.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added a TODO.

Comment thread src/adapt/schema.ts
type?: string;

/**
* [Optional] The precision for TIMESTAMP fields. 6 for microsecond, 12 for picosecond.
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.

nit: 9 for nanoseconds ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Comment thread src/adapt/proto.ts
danieljbruce and others added 2 commits February 25, 2026 11:18
Co-authored-by: Alvaro Viebrantz <aviebrantz@google.com>
@danieljbruce danieljbruce merged commit 5c90e88 into main Feb 25, 2026
19 of 21 checks passed
@danieljbruce danieljbruce deleted the picos-timestamp-feature branch February 25, 2026 16:37
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

api: bigquerystorage Issues related to the googleapis/nodejs-bigquery-storage API. size: xl Pull request size is extra large.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants