From 99b2137369d08b0ecfeb0207f8e66543a3dfec55 Mon Sep 17 00:00:00 2001 From: Tim Swast Date: Tue, 21 Nov 2017 09:39:24 -0800 Subject: [PATCH] Use shared reference property between Table and TableListItem. --- bigquery/google/cloud/bigquery/table.py | 40 ++++++++++--------------- 1 file changed, 15 insertions(+), 25 deletions(-) diff --git a/bigquery/google/cloud/bigquery/table.py b/bigquery/google/cloud/bigquery/table.py index 086679a3e7a8..1433842ef61a 100644 --- a/bigquery/google/cloud/bigquery/table.py +++ b/bigquery/google/cloud/bigquery/table.py @@ -34,6 +34,19 @@ _MARKER = object() +def _reference_getter(table): + """A :class:`~google.cloud.bigquery.table.TableReference` pointing to + this table. + + Returns: + google.cloud.bigquery.table.TableReference: pointer to this table + """ + from google.cloud.bigquery import dataset + + dataset_ref = dataset.DatasetReference(table.project, table.dataset_id) + return TableReference(dataset_ref, table.table_id) + + def _view_use_legacy_sql_getter(table): """Specifies whether to execute the view with Legacy or Standard SQL. @@ -223,19 +236,7 @@ def table_id(self): """ return self._table_id - @property - def reference(self): - """A :class:`~google.cloud.bigquery.table.TableReference` pointing to - this table. - - Returns: - google.cloud.bigquery.table.TableReference: - A pointer to this table - """ - from google.cloud.bigquery import dataset - - dataset_ref = dataset.DatasetReference(self.project, self.dataset_id) - return TableReference(dataset_ref, self.table_id) + reference = property(_reference_getter) @property def path(self): @@ -778,18 +779,7 @@ def table_id(self): """ return self._properties.get('tableReference', {}).get('tableId') - @property - def reference(self): - """A :class:`~google.cloud.bigquery.table.TableReference` pointing to - this table. - - Returns: - google.cloud.bigquery.table.TableReference: pointer to this table - """ - from google.cloud.bigquery import dataset - - dataset_ref = dataset.DatasetReference(self.project, self.dataset_id) - return TableReference(dataset_ref, self.table_id) + reference = property(_reference_getter) @property def labels(self):