Skip to content

Commit 304c2af

Browse files
xnuinsidekaxil
authored andcommitted
[AIRFLOW-2772] Fix Bug in BigQuery hook for Partitioned Table (#3901)
1 parent 7d60d26 commit 304c2af

File tree

3 files changed

+3
-21
lines changed

3 files changed

+3
-21
lines changed

airflow/contrib/hooks/bigquery_hook.py

+2-11
Original file line numberDiff line numberDiff line change
@@ -562,9 +562,7 @@ def run_query(self,
562562
The default value is INTERACTIVE.
563563
:type priority: str
564564
:param time_partitioning: configure optional time partitioning fields i.e.
565-
partition by field, type and
566-
expiration as per API specifications. Note that 'field' is not available in
567-
conjunction with dataset.table$partition.
565+
partition by field, type and expiration as per API specifications.
568566
:type time_partitioning: dict
569567
:param cluster_fields: Request that the result of this query be stored sorted
570568
by one or more columns. This is only available in combination with
@@ -926,9 +924,7 @@ def run_load(self,
926924
:param src_fmt_configs: configure optional fields specific to the source format
927925
:type src_fmt_configs: dict
928926
:param time_partitioning: configure optional time partitioning fields i.e.
929-
partition by field, type and
930-
expiration as per API specifications. Note that 'field' is not available in
931-
conjunction with dataset.table$partition.
927+
partition by field, type and expiration as per API specifications.
932928
:type time_partitioning: dict
933929
:param cluster_fields: Request that the result of this load be stored sorted
934930
by one or more columns. This is only available in combination with
@@ -1662,12 +1658,7 @@ def _cleanse_time_partitioning(destination_dataset_table, time_partitioning_in):
16621658

16631659
time_partitioning_out = {}
16641660
if destination_dataset_table and '$' in destination_dataset_table:
1665-
if time_partitioning_in.get('field'):
1666-
raise ValueError(
1667-
"Cannot specify field partition and partition name"
1668-
"(dataset.table$partition) at the same time")
16691661
time_partitioning_out['type'] = 'DAY'
1670-
16711662
time_partitioning_out.update(time_partitioning_in)
16721663
return time_partitioning_out
16731664

airflow/contrib/operators/bigquery_operator.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,7 @@ class BigQueryOperator(BaseOperator):
9696
The default value is INTERACTIVE.
9797
:type priority: str
9898
:param time_partitioning: configure optional time partitioning fields i.e.
99-
partition by field, type and
100-
expiration as per API specifications. Note that 'field' is not available in
101-
conjunction with dataset.table$partition.
99+
partition by field, type and expiration as per API specifications.
102100
:type time_partitioning: dict
103101
:param cluster_fields: Request that the result of this query be stored sorted
104102
by one or more columns. This is only available in conjunction with

tests/contrib/hooks/test_bigquery_hook.py

-7
Original file line numberDiff line numberDiff line change
@@ -447,13 +447,6 @@ def test_extra_time_partitioning_options(self):
447447
}
448448
self.assertEqual(tp_out, expect)
449449

450-
def test_cant_add_dollar_and_field_name(self):
451-
with self.assertRaises(ValueError):
452-
_cleanse_time_partitioning(
453-
'test.teast$20170101',
454-
{'type': 'DAY', 'field': 'test_field', 'expirationMs': 1000}
455-
)
456-
457450

458451
class TestClusteringInRunJob(unittest.TestCase):
459452

0 commit comments

Comments
 (0)