Movatterモバイル変換


[0]ホーム

URL:


Dataset

Dataset

Interact with your BigQuery dataset. Create a Dataset instance withBigQuery#createDataset orBigQuery#dataset.

Constructor

new Dataset(bigQuery, id, optionsopt)

Parameters:
NameTypeAttributesDescription
bigQueryBigQuery

BigQuery instance.

id string

The ID of the Dataset.

options object <optional>

Dataset options.

Properties
NameTypeAttributesDescription
projectId string <optional>

The GCP project ID.

location string <optional>

The geographic location of the dataset.Defaults to US.

Example
```const {BigQuery} = require('@google-cloud/bigquery');const bigquery = new BigQuery();const dataset = bigquery.dataset('institutions');```

Methods

create(callbackopt) → {Promise.<CreateDatasetResponse>}

Create a dataset.

Parameters:
NameTypeAttributesDescription
callbackCreateDatasetCallback <optional>

The callback function.

Properties
NameTypeAttributesDescription
err error <nullable>

An error returned while making thisrequest.

datasetDataset

The newly created dataset.

apiResponse object

The full API response.

Returns:
TypeDescription
Promise.<CreateDatasetResponse>
Example
```const {BigQuery} = require('@google-cloud/bigquery');const bigquery = new BigQuery();const dataset = bigquery.dataset('institutions');dataset.create((err, dataset, apiResponse) => {  if (!err) {    // The dataset was created successfully.  }});//-// If the callback is omitted, we'll return a Promise.//-dataset.create().then((data) => {  const dataset = data[0];  const apiResponse = data[1];});```

createQueryStream(options) → {stream}

Run a query scoped to your dataset as a readable object stream.

SeeBigQuery#createQueryStream for full documentation of thismethod.

Parameters:
NameTypeDescription
options object

SeeBigQuery#createQueryStream for fulldocumentation of this method.

Returns:
TypeDescription
stream

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

Check if the dataset exists.

Parameters:
NameTypeAttributesDescription
callbackDatasetExistsCallback <optional>

The callback function.

Properties
NameTypeAttributesDescription
err error <nullable>

An error returned while making thisrequest.

exists boolean

Whether the dataset exists or not.

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

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

Get a dataset if it exists.

You may optionally use this to "get or create" an object by providingan object withautoCreate set totrue. Any extra configuration thatis normally required for thecreate method must be contained withinthis object as well.

Parameters:
NameTypeAttributesDescription
options options <optional>

Configuration object.

Properties
NameTypeAttributesDefaultDescription
autoCreate boolean <optional>
false

Automatically create theobject if it does not exist.

callbackGetDatasetCallback <optional>

The callback function.

Properties
NameTypeAttributesDescription
err error <nullable>

An error returned while making thisrequest.

datasetDataset

The dataset.

apiResponse object

The full API response.

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

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

Get the metadata for the Dataset.

SeeDatasets: get API Documentation

Parameters:
NameTypeAttributesDescription
callbackGetDatasetMetadataCallback <optional>

The callback function.

Properties
NameTypeAttributesDescription
err error <nullable>

An error returned while making thisrequest.

metadata object

The dataset's metadata.

apiResponse object

The full API response.

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

getModelsStream(optionsopt) → {stream}

List all or some of theModel objects in your projectas a readable object stream.

Parameters:
NameTypeAttributesDescription
options object <optional>

Configuration object. SeeDataset#getModels for a complete list of options.

Returns:
TypeDescription
stream
Examples
```const {BigQuery} = require('@google-cloud/bigquery');const bigquery = new BigQuery();const dataset = bigquery.dataset('institutions');dataset.getModelsStream()  .on('error', console.error)  .on('data', (model) => {})  .on('end', () => {    // All models have been retrieved  });```
If you anticipate many results, you can end a stream early to prevent unnecessary processing and API requests.```dataset.getModelsStream()  .on('data', function(model) {    this.end();  });```

getRoutinesStream(optionsopt) → {stream}

List all or some of theRoutine objects in your project as areadable object stream.

Parameters:
NameTypeAttributesDescription
options GetRoutinesOptions <optional>

Configuration object.

Returns:
TypeDescription
stream
Examples
```const {BigQuery} = require('@google-cloud/bigquery');const bigquery = new BigQuery();const dataset = bigquery.dataset('institutions');dataset.getRoutinesStream()  .on('error', console.error)  .on('data', (routine) => {})  .on('end', () => {    // All routines have been retrieved  });```
If you anticipate many results, you can end a stream early to prevent unnecessary processing and API requests.```dataset.getRoutinesStream()  .on('data', function(routine) {    this.end();  });```

getTablesStream(optionsopt) → {stream}

List all or some of theTable objects in your projectas a readable object stream.

Parameters:
NameTypeAttributesDescription
options object <optional>

Configuration object. SeeDataset#getTables for a complete list of options.

Returns:
TypeDescription
stream
Example
```const {BigQuery} = require('@google-cloud/bigquery');const bigquery = new BigQuery();const dataset = bigquery.dataset('institutions');dataset.getTablesStream()  .on('error', console.error)  .on('data', (table) => {})  .on('end', () => {    // All tables have been retrieved  });//-// If you anticipate many results, you can end a stream early to prevent// unnecessary processing and API requests.//-dataset.getTablesStream()  .on('data', function(table) {    this.end();  });```

model(id) → {Model}

Create aModel object.

Parameters:
NameTypeDescription
id string

The ID of the model.

Returns:
TypeDescription
Model
Throws:

if model ID is missing.

Type
TypeError
Example
```const {BigQuery} = require('@google-cloud/bigquery');const bigquery = new BigQuery();const dataset = bigquery.dataset('institutions');const model = dataset.model('my-model');```

routine(id) → {Routine}

Create aRoutine object.

Parameters:
NameTypeDescription
id string

The ID of the routine.

Returns:
TypeDescription
Routine
Throws:

if routine ID is missing.

Type
TypeError
Example
```const {BigQuery} = require('@google-cloud/bigquery');const bigquery = new BigQuery();const dataset = bigquery.dataset('institutions');const routine = dataset.routine('my_routine');```

setMetadata(metadata, callbackopt) → {Promise.<SetDatasetMetadataResponse>}

Sets the metadata of the Dataset object.

SeeDatasets: patch API Documentation

Parameters:
NameTypeAttributesDescription
metadata object

Metadata to save on the Dataset.

callbackSetDatasetMetadataCallback <optional>

The callback function.

Properties
NameTypeAttributesDescription
err error <nullable>

An error returned while making thisrequest.

apiResponse object

The full API response.

Returns:
TypeDescription
Promise.<SetDatasetMetadataResponse>
Example
```const {BigQuery} = require('@google-cloud/bigquery');const bigquery = new BigQuery();const dataset = bigquery.dataset('institutions');const metadata = {  description: 'Info for every institution in the 2013 IPEDS universe'};dataset.setMetadata(metadata, (err, apiResponse) => {});//-// If the callback is omitted, we'll return a Promise.//-dataset.setMetadata(metadata).then((data) => {  const apiResponse = data[0];});```

table(id, optionsopt) → {Table}

Create aTable object.

Parameters:
NameTypeAttributesDescription
id string

The ID of the table.

options object <optional>

Table options.

Properties
NameTypeAttributesDescription
location string <optional>

The geographic location of the table, bydefault this value is inherited from the dataset. This can be used toconfigure the location of all jobs created through a table instance.It cannot be used to set the actual location of the table. This value willbe superseded by any API responses containing location data for thetable.

Returns:
TypeDescription
Table
Throws:

if table ID is missing.

Type
TypeError
Example
```const {BigQuery} = require('@google-cloud/bigquery');const bigquery = new BigQuery();const dataset = bigquery.dataset('institutions');const institutions = dataset.table('institution_data');```


[8]ページ先頭

©2009-2025 Movatter.jp