From 0dd90b90e3714c1d18f8a404917a9454870e338a Mon Sep 17 00:00:00 2001 From: shollyman Date: Wed, 13 May 2020 18:40:25 -0700 Subject: [PATCH] feat: add HOUR support for time partitioning interval (#91) * feat: add HOUR support for time partitioning interval --- google/cloud/bigquery/table.py | 5 +++-- tests/unit/test_table.py | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/google/cloud/bigquery/table.py b/google/cloud/bigquery/table.py index e674f237d..e66d24e74 100644 --- a/google/cloud/bigquery/table.py +++ b/google/cloud/bigquery/table.py @@ -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 " @@ -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. diff --git a/tests/unit/test_table.py b/tests/unit/test_table.py index 5bcd60986..72275fc53 100644 --- a/tests/unit/test_table.py +++ b/tests/unit/test_table.py @@ -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