Datasets#
Define API Datasets.
-
class
gcloud.bigquery.dataset.AccessGrant(role, entity_type, entity_id)[source]# Bases:
objectRepresent grant of an access role to an entity.
Parameters: - role (string (one of ‘OWNER’, ‘WRITER’, ‘READER’).) – role granted to the entity.
- entity_type (string (one of ‘specialGroup’, ‘groupByEmail’, or ‘userByEmail’)) – type of entity being granted the role.
- entity_id (string) – ID of entity being granted the role.
-
class
gcloud.bigquery.dataset.Dataset(name, client, access_grants=())[source]# Bases:
objectDatasets are containers for tables.
See: https://cloud.google.com/bigquery/docs/reference/v2/datasets
Parameters: - name (string) – the name of the dataset
- client (
gcloud.bigquery.client.Client) – A client which holds credentials and project configuration for the dataset (which requires a project). - access_grants (list of
AccessGrant) – roles granted to entities for this dataset
-
access_grants# Dataset’s access grants.
Return type: list of AccessGrantReturns: roles granted to entities for this dataset
-
create(client=None)[source]# API call: create the dataset via a PUT request
See: https://cloud.google.com/bigquery/reference/rest/v2/tables/insert
Parameters: client ( gcloud.bigquery.client.ClientorNoneType) – the client to use. If not passed, falls back to theclientstored on the current dataset.
-
created# Datetime at which the dataset was created.
Return type: datetime.datetime, orNoneTypeReturns: the creation time (None until set from the server).
-
dataset_id# ID for the dataset resource.
Return type: string, or NoneTypeReturns: the ID (None until set from the server).
-
default_table_expiration_ms# Default expiration time for tables in the dataset.
Return type: integer, or NoneTypeReturns: The time in milliseconds, or None (the default).
-
delete(client=None)[source]# API call: delete the dataset via a DELETE request
See: https://cloud.google.com/bigquery/reference/rest/v2/datasets/delete
Parameters: client ( gcloud.bigquery.client.ClientorNoneType) – the client to use. If not passed, falls back to theclientstored on the current dataset.
-
description# Description of the dataset.
Return type: string, or NoneTypeReturns: The description as set by the user, or None (the default).
-
etag# ETag for the dataset resource.
Return type: string, or NoneTypeReturns: the ETag (None until set from the server).
-
exists(client=None)[source]# API call: test for the existence of the dataset via a GET request
See https://cloud.google.com/bigquery/docs/reference/v2/datasets/get
Parameters: client ( gcloud.bigquery.client.ClientorNoneType) – the client to use. If not passed, falls back to theclientstored on the current dataset.
-
friendly_name# Title of the dataset.
Return type: string, or NoneTypeReturns: The name as set by the user, or None (the default).
-
classmethod
from_api_repr(resource, client)[source]# Factory: construct a dataset given its API representation
Parameters: - resource (dict) – dataset resource representation returned from the API
- client (
gcloud.bigquery.client.Client) – Client which holds credentials and project configuration for the dataset.
Return type: Returns: Dataset parsed from
resource.
-
list_tables(max_results=None, page_token=None)[source]# List tables for the project associated with this client.
See: https://cloud.google.com/bigquery/docs/reference/v2/tables/list
Parameters: Return type: tuple, (list, str)
Returns: list of
gcloud.bigquery.table.Table, plus a “next page token” string: if not None, indicates that more tables can be retrieved with another call (pass that value aspage_token).
-
location# Location in which the dataset is hosted.
Return type: string, or NoneTypeReturns: The location as set by the user, or None (the default).
-
modified# Datetime at which the dataset was last modified.
Return type: datetime.datetime, orNoneTypeReturns: the modification time (None until set from the server).
-
patch(client=None, **kw)[source]# API call: update individual dataset properties via a PATCH request
See https://cloud.google.com/bigquery/docs/reference/v2/datasets/patch
Parameters: - client (
gcloud.bigquery.client.ClientorNoneType) – the client to use. If not passed, falls back to theclientstored on the current dataset. - kw (
dict) – properties to be patched.
Raises: ValueError for invalid value types.
- client (
-
path# URL path for the dataset’s APIs.
Return type: string Returns: the path based on project and dataste name.
-
project# Project bound to the dataset.
Return type: string Returns: the project (derived from the client).
-
reload(client=None)[source]# API call: refresh dataset properties via a GET request
See https://cloud.google.com/bigquery/docs/reference/v2/datasets/get
Parameters: client ( gcloud.bigquery.client.ClientorNoneType) – the client to use. If not passed, falls back to theclientstored on the current dataset.
-
self_link# URL for the dataset resource.
Return type: string, or NoneTypeReturns: the URL (None until set from the server).
-
table(name, schema=())[source]# Construct a table bound to this dataset.
Parameters: - name (string) – Name of the table.
- schema (list of
gcloud.bigquery.table.SchemaField) – The table’s schema
Return type: Returns: a new
Tableinstance
-
update(client=None)[source]# API call: update dataset properties via a PUT request
See https://cloud.google.com/bigquery/docs/reference/v2/datasets/update
Parameters: client ( gcloud.bigquery.client.ClientorNoneType) – the client to use. If not passed, falls back to theclientstored on the current dataset.