Skip to content

Commit

Permalink
Add job failure handler
Browse files Browse the repository at this point in the history
  • Loading branch information
phanikumv committed Jun 20, 2023
1 parent 5ba04d8 commit cd746c9
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion airflow/providers/google/cloud/operators/bigquery.py
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,12 @@ def execute(self, context: Context) -> None: # type: ignore[override]
),
method_name="execute_complete",
)
self.log.info("Current state of job %s is %s", job.job_id, job.state)
self._handle_job_error(job)

@staticmethod
def _handle_job_error(job: BigQueryJob | UnknownJob) -> None:
if job.error_result:
raise AirflowException(f"BigQuery job {job.job_id} failed: {job.error_result}")

def execute_complete(self, context: Context, event: dict[str, Any]) -> None:
"""
Expand Down

0 comments on commit cd746c9

Please sign in to comment.