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

Adding clustering_fields property to TableListItem #7692

Merged
merged 2 commits into from
Apr 10, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
17 changes: 17 additions & 0 deletions bigquery/google/cloud/bigquery/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -1021,6 +1021,23 @@ def friendly_name(self):

view_use_legacy_sql = property(_view_use_legacy_sql_getter)

@property
def clustering_fields(self):
"""Union[List[str], None]: Fields defining clustering for the table

(Defaults to :data:`None`).

Clustering fields are immutable after table creation.

.. note::

As of 2018-06-29, clustering fields cannot be set on a table
which does not also have time partioning defined.
"""
prop = self._properties.get("clustering")
if prop is not None:
return list(prop.get("fields", ()))

@classmethod
def from_string(cls, full_table_id):
"""Construct a table from fully-qualified table ID.
Expand Down
1 change: 1 addition & 0 deletions bigquery/tests/unit/test_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -1170,6 +1170,7 @@ def test_ctor(self):
self.assertEqual(table.time_partitioning.field, "mycolumn")
self.assertEqual(table.labels["some-stuff"], "this-is-a-label")
self.assertIsNone(table.view_use_legacy_sql)
self.assertIsNone(table.clustering_fields)

with warnings.catch_warnings(record=True) as warned:
self.assertEqual(table.partitioning_type, "DAY")
Expand Down