From 855cb5f209e521ea5b4d64e415c952da6c77ae41 Mon Sep 17 00:00:00 2001 From: Seth Hollyman Date: Thu, 30 Apr 2020 19:33:08 +0000 Subject: [PATCH 1/2] 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 From e5a4ba0ddf1e165f87af29e98ec6c8e7fd72baf9 Mon Sep 17 00:00:00 2001 From: Seth Hollyman Date: Wed, 13 May 2020 23:07:07 +0000 Subject: [PATCH 2/2] address unrelated lint problem --- google/cloud/bigquery/job.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/google/cloud/bigquery/job.py b/google/cloud/bigquery/job.py index 25dd446e8..e4edfd162 100644 --- a/google/cloud/bigquery/job.py +++ b/google/cloud/bigquery/job.py @@ -3116,7 +3116,7 @@ def _format_for_exception(query, job_id): template = "\n\n(job ID: {job_id})\n\n{header}\n\n{ruler}\n{body}\n{ruler}" lines = query.splitlines() - max_line_len = max(len(l) for l in lines) + max_line_len = max(len(ln) for ln in lines) header = "-----Query Job SQL Follows-----" header = "{:^{total_width}}".format(header, total_width=max_line_len + 5)