Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .readme-partials.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -104,4 +104,8 @@ introduction: |-

Read more how to [use the BigQuery Storage Read API](https://cloud.google.com/bigquery/docs/reference/storage).

See sample code on the [Quickstart section](#quickstart).
See sample code on the [Quickstart section](#quickstart).

### Apache Arrow Picosecond Precision Limitation
Please note that the Apache Arrow JavaScript library currently does not support picosecond precision (`Timestamp[ps]`) logical types.
When using the Storage Read API with Arrow format, if picosecond precision is requested, the Node.js client library will automatically fall back to microsecond precision and log a warning to prevent deserialization errors.
18 changes: 18 additions & 0 deletions protos/google/cloud/bigquery/storage/v1/arrow.proto
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,25 @@ message ArrowSerializationOptions {
ZSTD = 2;
}

// Precision of the TIMESTAMP type.
enum PicosecondTimestampPrecision {
// If unspecified, microsecond precision will be used.
PICOSECOND_TIMESTAMP_PRECISION_UNSPECIFIED = 0;

// Use microsecond precision.
MICROSECOND = 1;

// Use nanosecond precision.
NANOSECOND = 2;

// Use picosecond precision.
PICOSECOND = 3;
}

// The compression codec to use for Arrow buffers in serialized record
// batches.
CompressionCodec buffer_compression = 2;

// The precision of the TIMESTAMP type.
PicosecondTimestampPrecision timestamp_precision = 3;
}
16 changes: 15 additions & 1 deletion protos/protos.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

75 changes: 73 additions & 2 deletions protos/protos.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 20 additions & 1 deletion protos/protos.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions src/v1/big_query_read_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,26 @@
this._gaxModule.routingHeader.fromParams({
'read_session.table': request.readSession!.table ?? '',
});

// Apache Arrow does not currently support picosecond precision in JavaScript.
// If picosecond precision is requested, we fall back to microsecond precision
// to avoid deserialization errors.
const timestampPrecision =
request.readSession?.readOptions?.arrowSerializationOptions
?.timestampPrecision;
if (
timestampPrecision ===
protos.google.cloud.bigquery.storage.v1.ArrowSerializationOptions
.PicosecondTimestampPrecision.PICOSECOND ||
timestampPrecision === 'PICOSECOND'
) {
console.warn(
'Apache Arrow does not support picosecond precision. Falling back to microsecond precision.'

Check failure on line 559 in src/v1/big_query_read_client.ts

View workflow job for this annotation

GitHub Actions / lint

Insert `,`
);
request.readSession!.readOptions!.arrowSerializationOptions!.timestampPrecision =
protos.google.cloud.bigquery.storage.v1.ArrowSerializationOptions.PicosecondTimestampPrecision.MICROSECOND;
}

this.initialize().catch(err => {
throw err;
});
Expand Down Expand Up @@ -575,7 +595,7 @@
return [response, options, rawResponse];
},
)
.catch((error: any) => {

Check warning on line 598 in src/v1/big_query_read_client.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected any. Specify a different type
if (
error &&
'statusDetails' in error &&
Expand Down Expand Up @@ -737,7 +757,7 @@
return [response, options, rawResponse];
},
)
.catch((error: any) => {

Check warning on line 760 in src/v1/big_query_read_client.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected any. Specify a different type
if (
error &&
'statusDetails' in error &&
Expand Down
Loading
Loading