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.table.TableReference

class google.cloud.bigquery.table.TableReference(dataset_ref, table_id)[source]

TableReferences are pointers to tables.

See https://cloud.google.com/bigquery/docs/reference/rest/v2/tables#tablereference

Parameters
__init__(dataset_ref, table_id)[source]

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

Methods

__init__(dataset_ref, table_id)

Initialize self.

from_api_repr(resource)

Factory: construct a table reference given its API representation

from_string(table_id[, default_project])

Construct a table reference from table ID string.

to_api_repr()

Construct the API resource representation of this table reference.

to_bqstorage()

Construct a BigQuery Storage API representation of this table.

Attributes

dataset_id

ID of dataset containing the table.

path

URL path for the table’s APIs.

project

Project bound to the table

table_id

The table ID.

property dataset_id

ID of dataset containing the table.

Type

str

classmethod from_api_repr(resource: dict)google.cloud.bigquery.table.TableReference[source]

Factory: construct a table reference given its API representation

Parameters

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

Returns

Table reference parsed from resource.

Return type

google.cloud.bigquery.table.TableReference

classmethod from_string(table_id: str, default_project: Optional[str] = None)google.cloud.bigquery.table.TableReference[source]

Construct a table reference from table ID string.

Parameters
  • table_id (str) – A table ID in standard SQL format. If default_project is not specified, this must included a project ID, dataset ID, and table ID, each separated by ..

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

Returns

Table reference parsed from table_id.

Return type

TableReference

Examples

>>> TableReference.from_string('my-project.mydataset.mytable')
TableRef...(DatasetRef...('my-project', 'mydataset'), 'mytable')
Raises

ValueError – If table_id is not a fully-qualified table ID in standard SQL format.

property path

URL path for the table’s APIs.

Type

str

property project

Project bound to the table

Type

str

property table_id

The table ID.

Type

str

to_api_repr()dict[source]

Construct the API resource representation of this table reference.

Returns

Table reference represented as an API resource

Return type

Dict[str, object]

to_bqstorage()str[source]

Construct a BigQuery Storage API representation of this table.

Install the google-cloud-bigquery-storage package to use this feature.

If the table_id contains a partition identifier (e.g. my_table$201812) or a snapshot identifier (e.g. mytable@1234567890), it is ignored. Use google.cloud.bigquery_storage.types.ReadSession.TableReadOptions to filter rows by partition. Use google.cloud.bigquery_storage.types.ReadSession.TableModifiers to select a specific snapshot to read from.

Returns

A reference to this table in the BigQuery Storage API.

Return type

str