Content-Length: 400411 | pFad | http://github.com/googleapis/google-cloud-python/commit/457da24c15e3f104de51a7c0c402ebf79dcc7389

9D Refactor table() methods into shared implementation. (#7516) · googleapis/google-cloud-python@457da24 · GitHub
Skip to content

Commit 457da24

Browse files
authored
Refactor table() methods into shared implementation. (#7516)
The method and docstring for the table() method are identical for Dataset, DatasetReference, and DatasetListItem. This commit moves the implementation to a shared method to reduce code duplication.
1 parent 67a6b85 commit 457da24

File tree

1 file changed

+16
-33
lines changed

1 file changed

+16
-33
lines changed

bigquery/google/cloud/bigquery/dataset.py

Lines changed: 16 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,19 @@
2424
from google.cloud.bigquery.table import TableReference
2525

2626

27+
def _get_table_reference(self, table_id):
28+
"""Constructs a TableReference.
29+
30+
Args:
31+
table_id (str): The ID of the table.
32+
33+
Returns:
34+
google.cloud.bigquery.table.TableReference:
35+
A table reference for a table in this dataset.
36+
"""
37+
return TableReference(self, table_id)
38+
39+
2740
class AccessEntry(object):
2841
"""Represents grant of an access role to an entity.
2942
@@ -191,17 +204,7 @@ def path(self):
191204
"""str: URL path for the dataset based on project and dataset ID."""
192205
return "/projects/%s/datasets/%s" % (self.project, self.dataset_id)
193206

194-
def table(self, table_id):
195-
"""Constructs a TableReference.
196-
197-
Args:
198-
table_id (str): The ID of the table.
199-
200-
Returns:
201-
google.cloud.bigquery.table.TableReference:
202-
A table reference for a table in this dataset.
203-
"""
204-
return TableReference(self, table_id)
207+
table = _get_table_reference
205208

206209
@classmethod
207210
def from_api_repr(cls, resource):
@@ -578,17 +581,7 @@ def _build_resource(self, filter_fields):
578581

579582
return partial
580583

581-
def table(self, table_id):
582-
"""Constructs a TableReference.
583-
584-
Args:
585-
table_id (str): the ID of the table.
586-
587-
Returns:
588-
google.cloud.bigquery.table.TableReference:
589-
A TableReference for a table in this dataset.
590-
"""
591-
return TableReference(self.reference, table_id)
584+
table = _get_table_reference
592585

593586
def __repr__(self):
594587
return "Dataset({})".format(repr(self.reference))
@@ -668,14 +661,4 @@ def reference(self):
668661
"""
669662
return DatasetReference(self.project, self.dataset_id)
670663

671-
def table(self, table_id):
672-
"""Constructs a TableReference.
673-
674-
Args:
675-
table_id (str): the ID of the table.
676-
677-
Returns:
678-
google.cloud.bigquery.table.TableReference:
679-
A TableReference for a table in this dataset.
680-
"""
681-
return TableReference(self.reference, table_id)
664+
table = _get_table_reference

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/googleapis/google-cloud-python/commit/457da24c15e3f104de51a7c0c402ebf79dcc7389

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy