Skip to content

Commit

Permalink
Allow setting partition expiration to 'None'. (#6823)
Browse files Browse the repository at this point in the history
  • Loading branch information
tswast authored and tseaver committed Dec 3, 2018
1 parent 1e8907b commit e9ddb89
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
5 changes: 4 additions & 1 deletion bigquery/google/cloud/bigquery/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -1335,7 +1335,10 @@ def expiration_ms(self):

@expiration_ms.setter
def expiration_ms(self, value):
self._properties["expirationMs"] = str(value)
if value is not None:
# Allow explicitly setting the expiration to None.
value = str(value)
self._properties["expirationMs"] = value

@property
def require_partition_filter(self):
Expand Down
5 changes: 5 additions & 0 deletions bigquery/tests/unit/test_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -1683,3 +1683,8 @@ def test___repr___explicit(self):
"type=DAY)"
)
self.assertEqual(repr(time_partitioning), expected)

def test_set_expiration_w_none(self):
time_partitioning = self._make_one()
time_partitioning.expiration_ms = None
assert time_partitioning._properties["expirationMs"] is None

0 comments on commit e9ddb89

Please sign in to comment.