Movatterモバイル変換


[0]ホーム

URL:


Job

Job

Job objects are returned from various places in the BigQuery API:

They can be used to check the status of a running job or fetching the resultsof a previously-executed one.

Constructor

new Job(bigQuery, id, optionsopt)

Parameters:
NameTypeAttributesDescription
bigQueryBigQuery

BigQuery instance.

id string

The ID of the job.

options object <optional>

Configuration object.

Properties
NameTypeAttributesDescription
location string <optional>

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.

Example
```const through2 = require('through2');const fs = require('fs');const {BigQuery} = require('@google-cloud/bigquery');const bigquery = new BigQuery();const job = bigquery.job('job-id');job.getQueryResultsStream()  .pipe(through2.obj(function (row, enc, next) {    this.push(JSON.stringify(row) + '\n');    next();  }))  .pipe(fs.createWriteStream('./test/testdata/testfile.json'));```

Methods

delete(callbackopt) → {Promise.<DeleteJobResponse>}

Delete the job.

Parameters:
NameTypeAttributesDescription
callbackDeleteJobCallback <optional>

The callback function.

Properties
NameTypeAttributesDescription
err error <nullable>

An error returned while making thisrequest.

apiResponse object

The full API response.

Returns:
TypeDescription
Promise.<DeleteJobResponse>
See:
Examples
const {BigQuery} = require('@google-cloud/bigquery');const bigquery = new BigQuery();const job = bigquery.job(jobId);job.delete((err, apiResponse) => {  if (!err) {    // The job was deleted successfully.  }});
If the callback is omitted a Promise will be returnedconst [apiResponse] = await job.delete();

exists(callbackopt) → {Promise.<JobExistsResponse>}

Check if the job exists.

Parameters:
NameTypeAttributesDescription
callbackJobExistsCallback <optional>

The callback function.

Properties
NameTypeAttributesDescription
err error <nullable>

An error returned while making thisrequest.

exists boolean

Whether the job exists or not.

Returns:
TypeDescription
Promise.<JobExistsResponse>
Example
```const {BigQuery} = require('@google-cloud/bigquery');const bigquery = new BigQuery();const job = bigquery.job('job-id');job.exists((err, exists) => {});//-// If the callback is omitted, we'll return a Promise.//-job.exists().then((data) => {  const exists = data[0];});```

get(optionsopt, callbackopt) → {Promise.<GetJobResponse>}

Get a job if it exists.

Parameters:
NameTypeAttributesDescription
options object <optional>

Configuration object.

Properties
NameTypeAttributesDescription
location string <optional>

The geographic location of the job.Required except for US and EU.

callbackGetJobCallback <optional>

The callback function.

Properties
NameTypeAttributesDescription
err error <nullable>

An error returned while making thisrequest.

jobJob

The job.

Returns:
TypeDescription
Promise.<GetJobResponse>
Example
```const {BigQuery} = require('@google-cloud/bigquery');const bigquery = new BigQuery();const job = bigquery.job('job-id');job.get((err, job, apiResponse) => {  if (!err) {    // `job.metadata` has been populated.  }});//-// If the callback is omitted, we'll return a Promise.//-job.get().then((data) => {  const job = data[0];  const apiResponse = data[1];});```

getMetadata(callbackopt) → {Promise.<GetJobMetadataResponse>}

Get the metadata of the job. This will mostly be useful for checkingthe status of a previously-run job.

SeeJobs: get API Documentation

Parameters:
NameTypeAttributesDescription
callbackGetJobMetadataCallback <optional>

The callback function.

Properties
NameTypeAttributesDescription
err error <nullable>

An error returned while making thisrequest.

metadata object

The metadata of the job.

apiResponse object

The full API response.

Returns:
TypeDescription
Promise.<GetJobMetadataResponse>
Example
```const {BigQuery} = require('@google-cloud/bigquery');const bigquery = new BigQuery();const job = bigquery.job('id');job.getMetadata((err, metadata, apiResponse) => {});//-// If the callback is omitted, we'll return a Promise.//-job.getMetadata().then((data) => {  const metadata = data[0];  const apiResponse = data[1];});```


[8]ページ先頭

©2009-2025 Movatter.jp