Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bigquery: rename name field of Dataset to dataset_id #3955

Merged
merged 3 commits into from
Sep 14, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 13 additions & 12 deletions bigquery/google/cloud/bigquery/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,8 @@ class Dataset(object):
See
https://cloud.google.com/bigquery/docs/reference/rest/v2/datasets

:type name: str
:param name: the name of the dataset
:type dataset_id: str
:param dataset_id: the ID of the dataset

:type client: :class:`google.cloud.bigquery.client.Client`
:param client: A client which holds credentials and project configuration
Expand All @@ -159,8 +159,8 @@ class Dataset(object):

_access_entries = None

def __init__(self, name, client, access_entries=(), project=None):
self.name = name
def __init__(self, dataset_id, client, access_entries=(), project=None):
self.dataset_id = dataset_id
self._client = client
self._properties = {}
# Let the @property do validation.
Expand All @@ -181,9 +181,9 @@ def path(self):
"""URL path for the dataset's APIs.

:rtype: str
:returns: the path based on project and dataste name.
:returns: the path based on project and dataset ID.
"""
return '/projects/%s/datasets/%s' % (self.project, self.name)
return '/projects/%s/datasets/%s' % (self.project, self.dataset_id)

@property
def access_entries(self):
Expand Down Expand Up @@ -221,8 +221,8 @@ def created(self):
return _datetime_from_microseconds(1000.0 * creation_time)

@property
def dataset_id(self):
"""ID for the dataset resource.
def full_dataset_id(self):

This comment was marked as spam.

This comment was marked as spam.

"""ID for the dataset resource, in the form "project_id:dataset_id".

:rtype: str, or ``NoneType``
:returns: the ID (None until set from the server).
Expand Down Expand Up @@ -365,8 +365,8 @@ def from_api_repr(cls, resource, client):
'datasetId' not in resource['datasetReference']):
raise KeyError('Resource lacks required identity information:'
'["datasetReference"]["datasetId"]')
name = resource['datasetReference']['datasetId']
dataset = cls(name, client=client)
dataset_id = resource['datasetReference']['datasetId']
dataset = cls(dataset_id, client=client)
dataset._set_properties(resource)
return dataset

Expand Down Expand Up @@ -444,7 +444,7 @@ def _build_resource(self):
"""Generate a resource for ``create`` or ``update``."""
resource = {
'datasetReference': {
'projectId': self.project, 'datasetId': self.name},
'projectId': self.project, 'datasetId': self.dataset_id},
}
if self.default_table_expiration_ms is not None:
value = self.default_table_expiration_ms
Expand Down Expand Up @@ -610,7 +610,8 @@ def list_tables(self, max_results=None, page_token=None):
:returns: Iterator of :class:`~google.cloud.bigquery.table.Table`
contained within the current dataset.
"""
path = '/projects/%s/datasets/%s/tables' % (self.project, self.name)
path = '/projects/%s/datasets/%s/tables' % (
self.project, self.dataset_id)
result = page_iterator.HTTPIterator(
client=self._client,
api_request=self._client._connection.api_request,
Expand Down
12 changes: 6 additions & 6 deletions bigquery/google/cloud/bigquery/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -773,7 +773,7 @@ def _build_resource(self):
'sourceUris': self.source_uris,
'destinationTable': {
'projectId': self.destination.project,
'datasetId': self.destination.dataset_name,
'datasetId': self.destination.dataset_id,
'tableId': self.destination.name,
},
},
Expand Down Expand Up @@ -900,7 +900,7 @@ def _build_resource(self):

source_refs = [{
'projectId': table.project,
'datasetId': table.dataset_name,
'datasetId': table.dataset_id,
'tableId': table.name,
} for table in self.sources]

Expand All @@ -914,7 +914,7 @@ def _build_resource(self):
'sourceTables': source_refs,
'destinationTable': {
'projectId': self.destination.project,
'datasetId': self.destination.dataset_name,
'datasetId': self.destination.dataset_id,
'tableId': self.destination.name,
},
},
Expand Down Expand Up @@ -1058,7 +1058,7 @@ def _build_resource(self):

source_ref = {
'projectId': self.source.project,
'datasetId': self.source.dataset_name,
'datasetId': self.source.dataset_id,
'tableId': self.source.name,
}

Expand Down Expand Up @@ -1247,7 +1247,7 @@ def _destination_table_resource(self):
if self.destination is not None:
return {
'projectId': self.destination.project,
'datasetId': self.destination.dataset_name,
'datasetId': self.destination.dataset_id,
'tableId': self.destination.name,
}

Expand All @@ -1271,7 +1271,7 @@ def _populate_config_resource(self, configuration):
if self.default_dataset is not None:
configuration['defaultDataset'] = {
'projectId': self.default_dataset.project,
'datasetId': self.default_dataset.name,
'datasetId': self.default_dataset.dataset_id,
}
if self.destination is not None:
table_res = self._destination_table_resource()
Expand Down
2 changes: 1 addition & 1 deletion bigquery/google/cloud/bigquery/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ def _build_resource(self):
if self.default_dataset is not None:
resource['defaultDataset'] = {
'projectId': self.project,
'datasetId': self.default_dataset.name,
'datasetId': self.default_dataset.dataset_id,
}

if self.max_results is not None:
Expand Down
14 changes: 7 additions & 7 deletions bigquery/google/cloud/bigquery/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,13 +119,13 @@ def project(self):
return self._dataset.project

@property
def dataset_name(self):
"""Name of dataset containing the table.
def dataset_id(self):
"""ID of dataset containing the table.

:rtype: str
:returns: the ID (derived from the dataset).
"""
return self._dataset.name
return self._dataset.dataset_id

@property
def path(self):
Expand Down Expand Up @@ -463,7 +463,7 @@ def list_partitions(self, client=None):
"""
query = self._require_client(client).run_sync_query(

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

'SELECT partition_id from [%s.%s$__PARTITIONS_SUMMARY__]' %
(self.dataset_name, self.name))
(self.dataset_id, self.name))
query.run()
return [row[0] for row in query.rows]

Expand Down Expand Up @@ -527,7 +527,7 @@ def _build_resource(self):
resource = {
'tableReference': {
'projectId': self._dataset.project,
'datasetId': self._dataset.name,
'datasetId': self._dataset.dataset_id,
'tableId': self.name},
}
if self.description is not None:
Expand Down Expand Up @@ -572,7 +572,7 @@ def create(self, client=None):
"""
client = self._require_client(client)
path = '/projects/%s/datasets/%s/tables' % (
self._dataset.project, self._dataset.name)
self._dataset.project, self._dataset.dataset_id)
api_response = client._connection.api_request(
method='POST', path=path, data=self._build_resource())
self._set_properties(api_response)
Expand Down Expand Up @@ -1361,7 +1361,7 @@ def _get_upload_metadata(source_format, schema, dataset, name):
'sourceFormat': source_format,
'destinationTable': {
'projectId': dataset.project,
'datasetId': dataset.name,
'datasetId': dataset.dataset_id,
'tableId': name,
},
}
Expand Down
Loading