As of January 1, 2020 this library no longer supports Python 2 on the latest released version. Library versions released prior to that date will continue to be available. For more information please visit Python 2 support on Google Cloud.

google.cloud.bigquery.dataset.DatasetReference

class google.cloud.bigquery.dataset.DatasetReference(project, dataset_id)[source]

DatasetReferences are pointers to datasets.

See https://cloud.google.com/bigquery/docs/reference/rest/v2/datasets#datasetreference

Parameters
  • project (str) – The ID of the project

  • dataset_id (str) – The ID of the dataset

Raises

ValueError – If either argument is not of type str.

__init__(project, dataset_id)[source]

Initialize self. See help(type(self)) for accurate signature.

Methods

__init__(project, dataset_id)

Initialize self.

from_api_repr(resource)

Factory: construct a dataset reference given its API representation

from_string(dataset_id[, default_project])

Construct a dataset reference from dataset ID string.

model(model_id)

Constructs a ModelReference.

routine(routine_id)

Constructs a RoutineReference.

table(table_id)

Constructs a TableReference.

to_api_repr()

Construct the API resource representation of this dataset reference

Attributes

dataset_id

Dataset ID.

path

URL path for the dataset based on project and dataset ID.

project

Project ID of the dataset.

property dataset_id

Dataset ID.

Type

str

classmethod from_api_repr(resource: dict)google.cloud.bigquery.dataset.DatasetReference[source]

Factory: construct a dataset reference given its API representation

Parameters

resource (Dict[str, str]) – Dataset reference resource representation returned from the API

Returns

Dataset reference parsed from resource.

Return type

google.cloud.bigquery.dataset.DatasetReference

classmethod from_string(dataset_id: str, default_project: Optional[str] = None)google.cloud.bigquery.dataset.DatasetReference[source]

Construct a dataset reference from dataset ID string.

Parameters
  • dataset_id (str) – A dataset ID in standard SQL format. If default_project is not specified, this must include both the project ID and the dataset ID, separated by ..

  • default_project (Optional[str]) – The project ID to use when dataset_id does not include a project ID.

Returns

Dataset reference parsed from dataset_id.

Return type

DatasetReference

Examples

>>> DatasetReference.from_string('my-project-id.some_dataset')
DatasetReference('my-project-id', 'some_dataset')
Raises

ValueError – If dataset_id is not a fully-qualified dataset ID in standard SQL format.

model(model_id)

Constructs a ModelReference.

Parameters

model_id (str) – the ID of the model.

Returns

A ModelReference for a model in this dataset.

Return type

google.cloud.bigquery.model.ModelReference

property path

URL path for the dataset based on project and dataset ID.

Type

str

property project

Project ID of the dataset.

Type

str

routine(routine_id)

Constructs a RoutineReference.

Parameters

routine_id (str) – the ID of the routine.

Returns

A RoutineReference for a routine in this dataset.

Return type

google.cloud.bigquery.routine.RoutineReference

table(table_id: str)google.cloud.bigquery.table.TableReference

Constructs a TableReference.

Parameters

table_id (str) – The ID of the table.

Returns

A table reference for a table in this dataset.

Return type

google.cloud.bigquery.table.TableReference

to_api_repr()dict[source]

Construct the API resource representation of this dataset reference

Returns

dataset reference represented as an API resource

Return type

Dict[str, str]