Skip to content

Commit

Permalink
Use shared reference property between Table and TableListItem.
Browse files Browse the repository at this point in the history
  • Loading branch information
tswast committed Nov 21, 2017
1 parent f24872d commit 31012a0
Showing 1 changed file with 15 additions and 25 deletions.
40 changes: 15 additions & 25 deletions bigquery/google/cloud/bigquery/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit 31012a0

Please sign in to comment.