Datasets#
Define API Datasets.
-
class
google.cloud.bigquery.dataset.
AccessGrant
(role, entity_type, entity_id)[source]# Bases:
object
Represent grant of an access role to an entity.
Every entry in the access list will have exactly one of
userByEmail
,groupByEmail
,domain
,specialGroup
orview
set. And if anything butview
is set, it’ll also have arole
specified.role
is omitted for aview
, sinceview
s are always read-only.See https://cloud.google.com/bigquery/docs/reference/v2/datasets.
Parameters: - role (string) –
Role granted to the entity. One of
'OWNER'
'WRITER'
'READER'
May also be
None
if theentity_type
isview
. - entity_type (string) – Type of entity being granted the role. One of
ENTITY_TYPES
. - entity_id (string) – ID of entity being granted the role.
Raises: ValueError
if theentity_type
is not amongENTITY_TYPES
, or if aview
hasrole
set or a nonview
does not have arole
set.-
ENTITY_TYPES
= frozenset(['specialGroup', 'groupByEmail', 'userByEmail', 'domain', 'view'])# Allowed entity types.
- role (string) –
-
class
google.cloud.bigquery.dataset.
Dataset
(name, client, access_grants=())[source]# Bases:
object
Datasets are containers for tables.
See: https://cloud.google.com/bigquery/docs/reference/v2/datasets
Parameters: - name (string) – the name of the dataset
- client (
google.cloud.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 AccessGrant
Returns: 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/docs/reference/v2/tables/insert
Parameters: client ( Client
orNoneType
) – the client to use. If not passed, falls back to theclient
stored on the current dataset.
-
created
# Datetime at which the dataset was created.
Return type: datetime.datetime
, orNoneType
Returns: the creation time (None until set from the server).
-
dataset_id
# ID for the dataset resource.
Return type: string, or NoneType
Returns: the ID (None until set from the server).
-
default_table_expiration_ms
# Default expiration time for tables in the dataset.
Return type: integer, or NoneType
Returns: 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/docs/reference/v2/tables/delete
Parameters: client ( Client
orNoneType
) – the client to use. If not passed, falls back to theclient
stored on the current dataset.
-
description
# Description of the dataset.
Return type: string, or NoneType
Returns: The description as set by the user, or None (the default).
-
etag
# ETag for the dataset resource.
Return type: string, or NoneType
Returns: 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 ( Client
orNoneType
) – the client to use. If not passed, falls back to theclient
stored on the current dataset.Return type: bool Returns: Boolean indicating existence of the dataset.
-
friendly_name
# Title of the dataset.
Return type: string, or NoneType
Returns: 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 (
google.cloud.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
google.cloud.bigquery.table.Table
, plus a “next page token” string: if notNone
, 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 NoneType
Returns: The location as set by the user, or None (the default).
-
modified
# Datetime at which the dataset was last modified.
Return type: datetime.datetime
, orNoneType
Returns: 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 (
Client
orNoneType
) – the client to use. If not passed, falls back to theclient
stored 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 ( Client
orNoneType
) – the client to use. If not passed, falls back to theclient
stored on the current dataset.
-
self_link
# URL for the dataset resource.
Return type: string, or NoneType
Returns: 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
google.cloud.bigquery.table.SchemaField
) – The table’s schema
Return type: Returns: a new
Table
instance
-
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 ( Client
orNoneType
) – the client to use. If not passed, falls back to theclient
stored on the current dataset.