google.cloud.bigquery.table.TableReference#

Methods

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.


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

Bases: object

TableReferences are pointers to tables.

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

Parameters
property dataset_id#

ID of dataset containing the table.

Type

str

classmethod from_api_repr(resource)[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, default_project=None)[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 (str) – Optional. 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()[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()[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_v1beta1.types.TableReadOptions to filter rows by partition. Use google.cloud.bigquery_storage_v1beta1.types.TableModifiers to select a specific snapshot to read from.

Returns

A reference to this table in the BigQuery Storage API.

Return type

google.cloud.bigquery_storage_v1beta1.types.TableReference

Raises

ValueError – If the google.cloud.bigquery_storage_v1beta1 module cannot be imported.