Skip to content

BigQueryValueCheckTrigger and BigQueryIntervalCheckTrigger fail while the BigQuery job is still running #73981

Closed

Description

@roykoand

Under which category would you file this issue?

Providers

Apache Airflow version

main (dev)

What happened and how to reproduce it?

In deferrable mode, BigQueryValueCheckOperator and BigQueryIntervalCheckOperator fail with the message Job running while the BigQuery job is still executing normally.

BigQueryAsyncHook.get_job_status() returns the job state as-is for any job that isn't DONE, so a job in progress reports either "pending" or "running":

if job.state == "DONE":
if job.error_result:
return {"status": "error", "message": job.error_result["message"]}
return {"status": "success", "message": "Job completed"}
return {"status": str(job.state).lower(), "message": "Job running"}

Both triggers treat only "pending" as "still in progress" and send every other status, including "running", to the error branch:

BigQueryValueCheckTrigger.run():

elif response_from_hook["status"] == "pending":
self.log.info("Query is still running...")
self.log.info("Sleeping for %s seconds.", self.poll_interval)
await asyncio.sleep(self.poll_interval)
else:
yield TriggerEvent(
{"status": "error", "message": response_from_hook["message"], "records": None}
)
return

BigQueryIntervalCheckTrigger.run():

elif (
first_job_response_from_hook["status"] == "pending"
or second_job_response_from_hook["status"] == "pending"
):
self.log.info("Query is still running...")
self.log.info("Sleeping for %s seconds.", self.poll_interval)
await asyncio.sleep(self.poll_interval)

Repro:

  1. Use BigQueryValueCheckOperator(..., deferrable=True) (or BigQueryIntervalCheckOperator) with a query that takes longer than one poll_interval.
  2. The job moves to RUNNING, and the trigger yields {"status": "error", "message": "Job running"}.
  3. The task fails, even though the query would have succeeded.

There is a second problem in BigQueryIntervalCheckTrigger: the error event always uses the second job's message:

else:
yield TriggerEvent(
{"status": "error", "message": second_job_response_from_hook["message"], "data": None}
)
return

When the first job fails and the second succeeds, the task fails with Job completed and the real error is lost.

The other triggers in the same file use if success / elif error / else keep polling, so they don't have this problem. For example, BigQueryInsertJobTrigger.run():

if job_status["status"] == "success":
self.log.info("BigQuery Job succeeded")
yield TriggerEvent(
{
"job_id": self.job_id,
"status": job_status["status"],
"message": job_status["message"],
}
)
return
elif job_status["status"] == "error":
self.log.info("BigQuery Job failed: %s", job_status)
yield TriggerEvent(
{
"status": job_status["status"],
"message": job_status["message"],
}
)
return
else:
self.log.info(
"Bigquery job status is %s. Sleeping for %s seconds.",
job_status["status"],
self.poll_interval,
)
await asyncio.sleep(self.poll_interval)

Existing tests only mock the "pending" status, never "running", which is why this wasn't caught:

async def test_interval_check_trigger_pending(self, mock_job_status, caplog, interval_check_trigger):
"""
Tests that the BigQueryIntervalCheckTrigger do not fire while a query is still running.
"""
mock_job_status.return_value = {"status": "pending", "message": "Job pending"}

async def test_value_check_op_trigger_pending(self, mock_job_status, caplog, value_check_trigger):
"""
Tests BigQueryValueCheckTrigger only fires once the query execution reaches a successful state.
"""
mock_job_status.return_value = {"status": "pending", "message": "Job pending"}

What you think should happen instead?

Any status that is neither success nor error (including running) should keep polling, matching the other triggers in the same module. BigQueryIntervalCheckTrigger should report the message of the job that actually failed.

Operating System

No response

Deployment

None

Apache Airflow Provider(s)

No response

Versions of Apache Airflow Providers

apache-airflow-providers-google 22.5.0

Official Helm Chart version

Not Applicable

Kubernetes Version

No response

Helm Chart configuration

No response

Docker Image customizations

No response

Anything else?

No response

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Code of Conduct

Activity

  1. added
    kind:bug
    needs-triage
    on Sep 30, 2026
  2. bingqin2 commented on Sep 30, 2026

    @bingqin2
    Contributor

    I'd like to fix this. @roykoand, you left the PR box unticked, so I'm picking it up; say so if you would rather do it yourself.

    The fix gives both triggers the order the other triggers in the module already use: success, then error, then keep polling for any other status. BigQueryIntervalCheckTrigger also reports the job that failed. One more effect of the same branch: while one job has failed and the other is still pending, the interval check keeps polling until the other job finishes, instead of failing right away. The PR covers that too.

  3. added
    provider:google
    and removed
    needs-triage
    on Oct 6, 2026
  4. added theissue type on Oct 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:providerskind:bugprovider:google

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions