diff --git a/bigquery/google/cloud/bigquery/dataset.py b/bigquery/google/cloud/bigquery/dataset.py index 9530eac9ee60..2a71c900baf0 100644 --- a/bigquery/google/cloud/bigquery/dataset.py +++ b/bigquery/google/cloud/bigquery/dataset.py @@ -24,6 +24,19 @@ from google.cloud.bigquery.table import TableReference +def _get_table_reference(self, table_id): + """Constructs a TableReference. + + Args: + table_id (str): The ID of the table. + + Returns: + google.cloud.bigquery.table.TableReference: + A table reference for a table in this dataset. + """ + return TableReference(self, table_id) + + class AccessEntry(object): """Represents grant of an access role to an entity. @@ -191,17 +204,7 @@ def path(self): """str: URL path for the dataset based on project and dataset ID.""" return "/projects/%s/datasets/%s" % (self.project, self.dataset_id) - def table(self, table_id): - """Constructs a TableReference. - - Args: - table_id (str): The ID of the table. - - Returns: - google.cloud.bigquery.table.TableReference: - A table reference for a table in this dataset. - """ - return TableReference(self, table_id) + table = _get_table_reference @classmethod def from_api_repr(cls, resource): @@ -578,17 +581,7 @@ def _build_resource(self, filter_fields): return partial - def table(self, table_id): - """Constructs a TableReference. - - Args: - table_id (str): the ID of the table. - - Returns: - google.cloud.bigquery.table.TableReference: - A TableReference for a table in this dataset. - """ - return TableReference(self.reference, table_id) + table = _get_table_reference def __repr__(self): return "Dataset({})".format(repr(self.reference)) @@ -668,14 +661,4 @@ def reference(self): """ return DatasetReference(self.project, self.dataset_id) - def table(self, table_id): - """Constructs a TableReference. - - Args: - table_id (str): the ID of the table. - - Returns: - google.cloud.bigquery.table.TableReference: - A TableReference for a table in this dataset. - """ - return TableReference(self.reference, table_id) + table = _get_table_reference