Skip to content

fix: BigQuery job error message - #34208

Merged
pankajastro merged 4 commits into
apache:mainfrom
king:bq_insert_job_terminated
Sep 9, 2023
Merged

fix: BigQuery job error message#34208
pankajastro merged 4 commits into
apache:mainfrom
king:bq_insert_job_terminated

Conversation

@nathadfield

@nathadfield nathadfield commented Sep 8, 2023

Copy link
Copy Markdown
Contributor

closes: #34162

As mentioned on the issue, currently if a BigQuery job running in deferrable mode ends unsuccessfully during execution - perhaps by cancellation in the BigQuery UI or if the job runs out of resources - then the only message that is returned to logs is the rather unhelpful

[2023-09-08, 11:43:22 UTC] {taskinstance.py:1939} ERROR - Task failed with exception
Traceback (most recent call last):
  File "/opt/airflow/airflow/models/baseoperator.py", line 1613, in resume_execution
    return execute_callable(context)
  File "/opt/airflow/airflow/providers/google/cloud/operators/bigquery.py", line 2881, in execute_complete
    raise AirflowException(event["message"])
KeyError: 'message'

This is due to the fact that the async function get_job_status only returns the string error and the actual error message is left behind.

The change involved here is to return a dictionary object that contains both status and a message which, when a BQ job is in a DONE state but contains an errorResult, then the specific error is carried through.

This then results in the following error output when the job is cancelled from the UI.

[2023-09-08, 08:21:20 UTC] {taskinstance.py:1939} ERROR - Task failed with exception
Traceback (most recent call last):
  File "/opt/airflow/airflow/models/baseoperator.py", line 1613, in resume_execution
    return execute_callable(context)
  File "/opt/airflow/airflow/providers/google/cloud/operators/bigquery.py", line 2881, in execute_complete
    raise AirflowException(event["message"])
airflow.exceptions.AirflowException: Job execution was cancelled: User requested cancellation

@boring-cyborg boring-cyborg Bot added area:providers provider:google Google (including GCP) related issues labels Sep 8, 2023
@pankajastro
pankajastro merged commit 774125a into apache:main Sep 9, 2023
@nathadfield
nathadfield deleted the bq_insert_job_terminated branch September 13, 2023 13:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:providers provider:google Google (including GCP) related issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BigQueryInsertJobOperator doesn't handle job errors caused by running tasks in deferrable mode

2 participants