Closed
Description
Environment details
- OS: OSx
- Node.js version: 20.12.1
- npm version: 10.5.0
@google-cloud/bigquery
version: 7.5.2
Steps to reproduce
- For a given row in a BQ table, have a timestamp column value of
1970-01-01 00:00:00 UTC
(aka timestamp0
) - Run a query +
getQueryResults()
to fetch the row
const [job] = await createQueryJob({ query: "SELECT * FROM .... " });
const [result] = await job.getQueryResults(); // ---- Error: TypeError: Cannot convert a BigInt value to a number at PreciseDate
Here's the stack trace of the error:
at new Date (<anonymous>)
at new PreciseDate (<{PATH}>/node_modules/@google-cloud/precise-date/build/src/index.js:95:26)
at new BigQueryTimestamp (<{PATH}>/node_modules/@google-cloud/bigquery/build/src/bigquery.js:1339:22)
at Function.timestamp (<{PATH}>/node_modules/@google-cloud/bigquery/build/src/bigquery.js:626:16)
at convert (<{PATH}>/node_modules/@google-cloud/bigquery/build/src/bigquery.js:374:38)
at <{PATH}>/node_modules/@google-cloud/bigquery/build/src/bigquery.js:310:29
at Array.map (<anonymous>)
at mergeSchema (<{PATH}>/node_modules/@google-cloud/bigquery/build/src/bigquery.js:301:26)
at Array.map (<anonymous>)
at Function.mergeSchemaWithRows_ (<{PATH}>/node_modules/@google-cloud/bigquery/build/src/bigquery.js:299:29)
at <{PATH}>/node_modules/@google-cloud/bigquery/build/src/job.js:368:44
at <{PATH}>/node_modules/@google-cloud/common/build/src/util.js:412:25
at Util.handleResp (<{PATH}>/node_modules/@google-cloud/common/build/src/util.js:161:9)
at <{PATH}>/node_modules/@google-cloud/common/build/src/util.js:534:22
at onResponse (<{PATH}>/node_modules/retry-request/index.js:259:7)
at <{PATH}>/node_modules/teeny-request/src/index.ts:333:11
at processTicksAndRejections (node:internal/process/task_queues:95:5)'
After investigating the issue, I noticed that the following statement is causing the error (class BigQueryTimestamp
> constructor
):
// @google-cloud/bigquery/build/src/bigquery.js:1339
pd = new precise_date_1.PreciseDate(BigInt(value) * BigInt(1000));
If value = "0"
, PreciseDate. constructor
will try to run new Date(BigInt("0"))
, which throws an error.
The issue was introduced by the client version 7.5.
Thanks!