google.cloud.bigquery.table.Table#
Methods
|
Factory: construct a table given its API representation |
|
Construct a table from fully-qualified table ID. |
Constructs the API resource of this table |
|
Construct a BigQuery Storage API representation of this table. |
Attributes
Fields defining clustering for the table |
|
Datetime at which the table was created ( |
|
ID of dataset containing the table. |
|
Description of the table (defaults to |
|
Custom encryption configuration for the table. |
|
ETag for the table resource ( |
|
Datetime at which the table will be deleted. |
|
Configuration for an external data source (defaults to |
|
Title of the table (defaults to |
|
ID for the table ( |
|
Labels for the table. |
|
Location in which the table is hosted |
|
Datetime at which the table was last modified ( |
|
The size of the table in bytes ( |
|
The number of rows in the table ( |
|
Expiration time in milliseconds for a partition. |
|
Time partitioning of the table if it is partitioned (Defaults to |
|
URL path for the table’s APIs. |
|
Project bound to the table. |
|
A |
|
Table’s schema. |
|
URL for the table resource ( |
|
Information about a table’s streaming buffer. |
|
ID of the table. |
|
The type of the table ( |
|
Configures time-based partitioning for a table. |
|
SQL query defining the table as a view (defaults to |
|
Specifies whether to execute the view with Legacy or Standard SQL. |
-
class
google.cloud.bigquery.table.
Table
(table_ref, schema=None)[source]# Bases:
object
Tables represent a set of rows whose values correspond to a schema.
See https://cloud.google.com/bigquery/docs/reference/rest/v2/tables
- Parameters
table_ref (Union[
TableReference
, str, ]) – A pointer to a table. Iftable_ref
is a string, it must included a project ID, dataset ID, and table ID, each separated by.
.schema (List[google.cloud.bigquery.schema.SchemaField]) – The table’s schema
-
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
partitioning_type
# Time partitioning of the table if it is partitioned (Defaults to
None
).The only partitioning type that is currently supported is
DAY
.
-
property
reference
# A
TableReference
pointing to this table.- Returns
pointer to this table.
- Return type
-
property
schema
# Table’s schema.
- Raises
TypeError – If ‘value’ is not a sequence
ValueError – If any item in the sequence is not a
SchemaField
- Type
-
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.
- Raises
ValueError – If the value is not
TimePartitioning
orNone
.- Type
-
to_bqstorage
()[source]# Construct a BigQuery Storage API representation of this table.
- Returns
A reference to this table in the BigQuery Storage API.
- Return type
google.cloud.bigquery_storage_v1beta1.types.TableReference
-
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