bingqin2 opened a new pull request, #74305:
URL: https://github.com/apache/airflow/pull/74305

   `BigQueryValueCheckTrigger` and `BigQueryIntervalCheckTrigger` treated only 
`"pending"` as in progress. `BigQueryAsyncHook.get_job_status()` returns the 
job state as it is until the job is `DONE`, so a query that is executing 
reports `"running"`, and both triggers sent that to the error branch. In 
deferrable mode, `BigQueryValueCheckOperator` and 
`BigQueryIntervalCheckOperator` therefore failed with `Job running` whenever 
the query outlived one poll interval (#73981).
   
   Both triggers now follow the order the other triggers in the module already 
use: success, then error, then keep polling for any other status. The hook only 
returns `success`, `error`, or the lowercased BigQuery job state (`pending` / 
`running`), so the polling branch cannot spin on an unexpected terminal status.
   
   For the interval check this also fixes which job's message is reported. The 
error branch always used the second job's message, so a failed first job 
surfaced as `Job completed`; and while one job had failed and the other was 
still `pending`, the trigger kept polling until the other finished. It now 
fails as soon as either job has failed, with that job's message.
   
   **Changes**
   
   - 
`providers/google/src/airflow/providers/google/cloud/triggers/bigquery.py`: 
`BigQueryValueCheckTrigger.run` and `BigQueryIntervalCheckTrigger.run` keep 
polling unless the job succeeded or failed; the interval check reports the 
failed job
   - `providers/google/tests/unit/google/cloud/triggers/test_bigquery.py`: 
`test_interval_check_trigger_keeps_polling_while_a_job_is_running` (first, 
second or both jobs running), 
`test_interval_check_trigger_reports_the_failed_job` (first failed, second 
failed, first failed while the second is still running) and 
`test_value_check_op_trigger_keeps_polling_while_job_is_running`. Six of the 
seven cases fail on main; the "second failed" case guards that the second job's 
message is still used when it is the one that failed. The polling tests patch 
`asyncio.sleep` and feed a status sequence, so they do not depend on timing.
   
   **Testing**
   
   - `providers/google`: `tests/unit/google/cloud/triggers/test_bigquery.py` 
(57 passed)
   - mypy on the changed module, prek hooks on the changed files
   - The deferrable value and interval checks run in 
`providers/google/tests/system/google/cloud/bigquery/example_bigquery_queries_async.py`;
 I don't have a GCP project to run it myself.
   
   closes: #73981
   
   ---
   
   ##### Was generative AI tooling used to co-author this PR?
   
   - [X] Yes (please specify the tool below)
   
   Generated-by: Claude Code (Claude Opus 5.5) following [the 
guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions).
 I reviewed and understand all changes; the tests were run locally as listed 
above.
   
   ---
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to