google.cloud.bigquery.table.Table¶
-
class
google.cloud.bigquery.table.
Table
(table_ref, schema=None)[source]¶ Tables represent a set of rows whose values correspond to a schema.
See https://cloud.google.com/bigquery/docs/reference/rest/v2/tables#resource-table
- Parameters
table_ref (Union[google.cloud.bigquery.table.TableReference, str]) – A pointer to a table. If
table_ref
is a string, it must included a project ID, dataset ID, and table ID, each separated by.
.schema (Optional[Sequence[Union[
SchemaField
, Mapping[str, Any] ]]]) – The table’s schema. If any item is a mapping, its content must be compatible withfrom_api_repr()
.
-
__init__
(table_ref, schema=None)[source]¶ Initialize self. See help(type(self)) for accurate signature.
Methods
__init__
(table_ref[, schema])Initialize self.
from_api_repr
(resource)Factory: construct a table given its API representation
from_string
(full_table_id)Construct a table from fully-qualified table ID.
Constructs the API resource of this table
to_bqstorage
([v1beta1])Construct a BigQuery Storage API representation of this table.
Attributes
Fields defining clustering for the table
Datetime at which the table was created (
None
until set from the server).ID of dataset containing the table.
Description of the table (defaults to
None
).Custom encryption configuration for the table.
ETag for the table resource (
None
until set from the server).Datetime at which the table will be deleted.
Configuration for an external data source (defaults to
None
).Title of the table (defaults to
None
).ID for the table (
None
until set from the server).Labels for the table.
Location in which the table is hosted
Datetime at which the table was last modified (
None
until set from the server).The size of the table in bytes (
None
until set from the server).The number of rows in the table (
None
until set from the server).Expiration time in milliseconds for a partition.
Time partitioning of the table if it is partitioned (Defaults to
None
).URL path for the table’s APIs.
Project bound to the table.
Optional[google.cloud.bigquery.table.RangePartitioning]: Configures range-based partitioning for a table.
A
TableReference
pointing to this table.If set to true, queries over the partitioned table require a partition filter that can be used for partition elimination to be specified.
Sequence[Union[
SchemaField
, Mapping[str, Any] ]]:URL for the table resource (
None
until set from the server).Information about a table’s streaming buffer.
ID of the table.
The type of the table (
None
until set from the server).Configures time-based partitioning for a table.
SQL query defining the table as a view (defaults to
None
).Specifies whether to execute the view with Legacy or Standard SQL.
-
property
clustering_fields
¶ Fields defining clustering for the table
(Defaults to
None
).Clustering fields are immutable after table creation.
Note
As of 2018-06-29, clustering fields cannot be set on a table which does not also have time partioning defined.
-
property
created
¶ Datetime at which the table was created (
None
until set from the server).- Type
Union[datetime.datetime, None]
-
property
description
¶ Description of the table (defaults to
None
).- Raises
ValueError – For invalid value types.
- Type
-
property
encryption_configuration
¶ Custom encryption configuration for the table.
Custom encryption configuration (e.g., Cloud KMS keys) or
None
if using default encryption.See protecting data with Cloud KMS keys in the BigQuery documentation.
-
property
expires
¶ Datetime at which the table will be deleted.
- Raises
ValueError – For invalid value types.
- Type
Union[datetime.datetime, None]
-
property
external_data_configuration
¶ Configuration for an external data source (defaults to
None
).- Raises
ValueError – For invalid value types.
- Type
Union[google.cloud.bigquery.ExternalConfig, None]
-
property
friendly_name
¶ Title of the table (defaults to
None
).- Raises
ValueError – For invalid value types.
- Type
-
classmethod
from_api_repr
(resource)[source]¶ Factory: construct a table given its API representation
- Parameters
resource (Dict[str, object]) – Table resource representation from the API
- Returns
Table parsed from
resource
.- Return type
- Raises
KeyError – If the
resource
lacks the key'tableReference'
, or if thedict
stored within the key'tableReference'
lacks the keys'tableId'
,'projectId'
, or'datasetId'
.
-
classmethod
from_string
(full_table_id)[source]¶ Construct a table from fully-qualified table ID.
- Parameters
full_table_id (str) – A fully-qualified table ID in standard SQL format. Must included a project ID, dataset ID, and table ID, each separated by
.
.- Returns
Table parsed from
full_table_id
.- Return type
Examples
>>> Table.from_string('my-project.mydataset.mytable') Table(TableRef...(D...('my-project', 'mydataset'), 'mytable'))
- Raises
ValueError – If
full_table_id
is not a fully-qualified table ID in standard SQL format.
-
property
full_table_id
¶ ID for the table (
None
until set from the server).In the format
project_id:dataset_id.table_id
.
-
property
labels
¶ Labels for the table.
This method always returns a dict. To change a table’s labels, modify the dict, then call
Client.update_table
. To delete a label, set its value toNone
before updating.- Raises
ValueError – If
value
type is invalid.- Type
-
property
modified
¶ Datetime at which the table was last modified (
None
until set from the server).- Type
Union[datetime.datetime, None]
-
property
partition_expiration
¶ Expiration time in milliseconds for a partition.
If
partition_expiration
is set andtype_
is not set,type_
will default toDAY
.
-
property
range_partitioning
¶ Optional[google.cloud.bigquery.table.RangePartitioning]: Configures range-based partitioning for a table.
Note
Beta. The integer range partitioning feature is in a pre-release state and might change or have limited support.
Only specify at most one of
time_partitioning
orrange_partitioning
.- Raises
ValueError – If the value is not
RangePartitioning
orNone
.
-
property
reference
¶ A
TableReference
pointing to this table.- Returns
pointer to this table.
- Return type
-
property
require_partition_filter
¶ If set to true, queries over the partitioned table require a partition filter that can be used for partition elimination to be specified.
- Type
-
property
schema
¶ - Sequence[Union[
SchemaField
, Mapping[str, Any] ]]: Table’s schema.
- Raises
Exception – If
schema
is not a sequence, or if any item in the sequence is not aSchemaField
instance or a compatible mapping representation of the field.
- Sequence[Union[
-
property
streaming_buffer
¶ Information about a table’s streaming buffer.
- Type
google.cloud.bigquery.StreamingBuffer
-
property
table_type
¶ The type of the table (
None
until set from the server).Possible values are
'TABLE'
,'VIEW'
, or'EXTERNAL'
.
-
property
time_partitioning
¶ Configures time-based partitioning for a table.
Only specify at most one of
time_partitioning
orrange_partitioning
.- Raises
ValueError – If the value is not
TimePartitioning
orNone
.- Type
-
property
view_query
¶ SQL query defining the table as a view (defaults to
None
).By default, the query is treated as Standard SQL. To use Legacy SQL, set
view_use_legacy_sql
toTrue
.- Raises
ValueError – For invalid value types.
- Type
-
property
view_use_legacy_sql
¶ Specifies whether to execute the view with Legacy or Standard SQL.
This boolean specifies whether to execute the view with Legacy SQL (
True
) or Standard SQL (False
). The client side default isFalse
. The server-side default isTrue
. If this table is not a view,None
is returned.- Raises
ValueError – For invalid value types.
- Type