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

getQueryResults does not provide response object if not specifying maxResults #1210

@MasterOdin

Description

@MasterOdin

Environment details

  • OS: macOS 13.4
  • Node.js version: 16.20
  • npm version: 8.19.4
  • @google-cloud/bigquery version: 6.2.0

Steps to reproduce

  1. Run the following script:
    import { BigQuery } from '@google-cloud/bigquery';
    
    const credentials = {
      /* service_credentials for a given project */
    };
    
    const bigquery = new BigQuery({
      credentials,
      projectId: credentials.project_id,
    });
    
    (async () => {
      const [job] = await bigquery.createQueryJob({
        query: 'SELECT 1 AS col',
      });
      const [rows, , response] = await job.getQueryResults({ maxResults: 1 });
      console.log(rows);
      console.log(response);
      const [rows2, , response2] = await job.getQueryResults();
      console.log(rows2);
      console.log(response2);
    })()
      .then(() => console.log('done'))
      .catch((err) => console.error(err));
  2. See that response prints out an object that can be used, while response2 is undefined. Order to the calls does not matter

While both response and response2 are typed as bigquery.IGetQueryResultsResponse | undefined, it's non-obvious from reading the docs as to when it should be defined vs not.

My use case was wanting to reference response2.schema and finding it not defined, and so having to run this initial fetch first to get the schema metadata, and then a second request to get all the rows.

Metadata

Metadata

Assignees

Labels

api: bigqueryIssues related to the googleapis/nodejs-bigquery API.priority: p3Desirable enhancement or fix. May not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions