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

feat: add HOUR support for time partitioning interval #91

Merged
merged 4 commits into from
May 14, 2020
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
5 changes: 3 additions & 2 deletions google/cloud/bigquery/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -583,8 +583,6 @@ def partitioning_type(self):
"""Union[str, None]: Time partitioning of the table if it is
partitioned (Defaults to :data:`None`).

The only partitioning type that is currently supported is
:attr:`~google.cloud.bigquery.table.TimePartitioningType.DAY`.
"""
warnings.warn(
"This method will be deprecated in future versions. Please use "
Expand Down Expand Up @@ -1980,6 +1978,9 @@ class TimePartitioningType(object):
DAY = "DAY"
"""str: Generates one partition per day."""

HOUR = "HOUR"
"""str: Generates one partition per hour."""


class TimePartitioning(object):
"""Configures time-based partitioning for a table.
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/test_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -1024,11 +1024,11 @@ def test_time_partitioning_setter(self):
dataset = DatasetReference(self.PROJECT, self.DS_ID)
table_ref = dataset.table(self.TABLE_NAME)
table = self._make_one(table_ref)
time_partitioning = TimePartitioning(type_=TimePartitioningType.DAY)
time_partitioning = TimePartitioning(type_=TimePartitioningType.HOUR)

table.time_partitioning = time_partitioning

self.assertEqual(table.time_partitioning.type_, TimePartitioningType.DAY)
self.assertEqual(table.time_partitioning.type_, TimePartitioningType.HOUR)
# Both objects point to the same properties dict
self.assertIs(
table._properties["timePartitioning"], time_partitioning._properties
Expand Down