The geographic location of the job.
Required except for US and EU.
Example
const {BigQuery} = require('@google-cloud/bigquery');
const bigquery = new BigQuery();
const job = bigquery.job('job-id');
//-
// All jobs are event emitters. The status of each job is polled
// continuously, starting only after you register a "complete" listener.
//-
job.on('complete', (metadata) => {
// The job is complete.
});
//-
// Be sure to register an error handler as well to catch any issues which
// impeded the job.
//-
job.on('error', (err) => {
// An error occurred during the job.
});
//-
// To force the Job object to stop polling for updates, simply remove any
// "complete" listeners you've registered.
//
// The easiest way to do this is with `removeAllListeners()`.
//-
job.removeAllListeners();
Members
getQueryResultsStream
Get the results of a job as a readable object stream.
Page token, returned by a previous call,
to request the next page of results. Note: This is automatically added
to the nextQuery argument of your callback.
startIndex
number
<optional>
Zero-based index of the starting row.
timeoutMs
number
<optional>
How long to wait for the query to
complete, in milliseconds, before returning. Default is 10 seconds.
If the timeout passes before the job completes, an error will be returned
and the 'jobComplete' field in the response will be false.
wrapIntegers
boolean
|
IntegerTypeCastOptions
<optional>
false
Wrap values
of 'INT64' type in BigQueryInt objects.
If a boolean, this will wrap values in BigQueryInt objects.
If an object, this will return a value returned by
wrapIntegers.integerTypeCastFunction.
const {BigQuery} = require('@google-cloud/bigquery');
const bigquery = new BigQuery();
const job = bigquery.job('job-id');
//-
// Get all of the results of a query.
//-
job.getQueryResults((err, rows) => {
if (!err) {
// rows is an array of results.
}
});
//-
// Customize the results you want to fetch.
//-
job.getQueryResults({
maxResults: 100
}, (err, rows) => {});
//-
// To control how many API requests are made and page through the results
// manually, set `autoPaginate` to `false`.
//-
function manualPaginationCallback(err, rows, nextQuery, apiResponse) {
if (nextQuery) {
// More results exist.
job.getQueryResults(nextQuery, manualPaginationCallback);
}
}
job.getQueryResults({
autoPaginate: false
}, manualPaginationCallback);
//-
// If the callback is omitted, we'll return a Promise.
//-
job.getQueryResults().then((data) => {
const rows = data[0];
});