You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Feb 7, 2026. It is now read-only.
import{BigQuery}from'@google-cloud/bigquery';constcredentials={/* service_credentials for a given project */};constbigquery=newBigQuery({
credentials,projectId: credentials.project_id,});(async()=>{const[job]=awaitbigquery.createQueryJob({query: 'SELECT 1 AS col',});const[rows,,response]=awaitjob.getQueryResults({maxResults: 1});console.log(rows);console.log(response);const[rows2,,response2]=awaitjob.getQueryResults();console.log(rows2);console.log(response2);})().then(()=>console.log('done')).catch((err)=>console.error(err));
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.
Environment details
@google-cloud/bigqueryversion: 6.2.0Steps to reproduce
responseprints out an object that can be used, whileresponse2isundefined. Order to the calls does not matterWhile both
responseandresponse2are typed asbigquery.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.schemaand 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.