Skip to content

Commit 9a0c10b

Browse files
author
Hossein Torabi
authored
deduplicate running jobs on BigQueryInsertJobOperator (#17496)
1 parent 6914091 commit 9a0c10b

File tree

2 files changed

+3
-6
lines changed

2 files changed

+3
-6
lines changed

airflow/providers/google/cloud/operators/bigquery.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2247,16 +2247,13 @@ def _submit_job(
22472247
hook: BigQueryHook,
22482248
job_id: str,
22492249
) -> BigQueryJob:
2250-
# Submit a new job
2251-
job = hook.insert_job(
2250+
# Submit a new job and wait for it to complete and get the result.
2251+
return hook.insert_job(
22522252
configuration=self.configuration,
22532253
project_id=self.project_id,
22542254
location=self.location,
22552255
job_id=job_id,
22562256
)
2257-
# Start the job and wait for it to complete and get the result.
2258-
job.result()
2259-
return job
22602257

22612258
@staticmethod
22622259
def _handle_job_error(job: BigQueryJob) -> None:

tests/providers/google/cloud/operators/test_bigquery.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -930,7 +930,7 @@ def test_execute_reattach(self, mock_hook, mock_md5):
930930
}
931931
}
932932

933-
mock_hook.return_value.insert_job.return_value.result.side_effect = Conflict("any")
933+
mock_hook.return_value.insert_job.side_effect = Conflict("any")
934934
job = MagicMock(
935935
job_id=real_job_id,
936936
error_result=False,

0 commit comments

Comments
 (0)