This is an automated email from the ASF dual-hosted git repository.
eladkal pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/main by this push:
new 9a0c10b deduplicate running jobs on BigQueryInsertJobOperator (#17496)
9a0c10b is described below
commit 9a0c10ba3fac3bb88f4f103114d4590b3fb191cb
Author: Hossein Torabi <[email protected]>
AuthorDate: Wed Sep 1 21:36:56 2021 +0200
deduplicate running jobs on BigQueryInsertJobOperator (#17496)
---
airflow/providers/google/cloud/operators/bigquery.py | 7 ++-----
tests/providers/google/cloud/operators/test_bigquery.py | 2 +-
2 files changed, 3 insertions(+), 6 deletions(-)
diff --git a/airflow/providers/google/cloud/operators/bigquery.py
b/airflow/providers/google/cloud/operators/bigquery.py
index fe853c2..e89d6a8 100644
--- a/airflow/providers/google/cloud/operators/bigquery.py
+++ b/airflow/providers/google/cloud/operators/bigquery.py
@@ -2247,16 +2247,13 @@ class BigQueryInsertJobOperator(BaseOperator):
hook: BigQueryHook,
job_id: str,
) -> BigQueryJob:
- # Submit a new job
- job = hook.insert_job(
+ # Submit a new job and wait for it to complete and get the result.
+ return hook.insert_job(
configuration=self.configuration,
project_id=self.project_id,
location=self.location,
job_id=job_id,
)
- # Start the job and wait for it to complete and get the result.
- job.result()
- return job
@staticmethod
def _handle_job_error(job: BigQueryJob) -> None:
diff --git a/tests/providers/google/cloud/operators/test_bigquery.py
b/tests/providers/google/cloud/operators/test_bigquery.py
index 801034c..1576b24 100644
--- a/tests/providers/google/cloud/operators/test_bigquery.py
+++ b/tests/providers/google/cloud/operators/test_bigquery.py
@@ -930,7 +930,7 @@ class TestBigQueryInsertJobOperator:
}
}
- mock_hook.return_value.insert_job.return_value.result.side_effect =
Conflict("any")
+ mock_hook.return_value.insert_job.side_effect = Conflict("any")
job = MagicMock(
job_id=real_job_id,
error_result=False,