steveahnahn opened a new pull request, #69635: URL: https://github.com/apache/airflow/pull/69635
### Problem A deferred `SnowflakeSqlApiOperator` parks its running query ids in the triggerer, so the operator's own `on_kill` no longer runs once the task is deferred. When a user marks that task failed, clears it, or marks it success, `SnowflakeSqlApiTrigger` had no `on_kill` hook, so the Snowflake statements kept executing on the warehouse, burning compute credits, even though the operator already cancels the queries on kill in the non-deferred path. ### Change `SnowflakeSqlApiTrigger` gains an `on_kill` that cancels the running query ids when the user acts on the deferred task. This matches the behaviour already shipped for the EMR, Dataproc, BigQuery, and Dataflow triggers. The Snowflake SQL API cancel is a blocking `POST` with no async variant (the hook's async helper is `GET` only), so `on_kill` runs `cancel_queries` through `sync_to_async` to keep it off the triggerer event loop, and it builds the hook inside that worker so no connection work touches the loop. A `cancel_on_kill` flag (default `True`) is added to both `SnowflakeSqlApiOperator` and `SnowflakeSqlApiTrigger` so users can opt out, and the operator threads it into the trigger at the defer site. Cancellation is best effort: failures while cancelling are logged and swallowed so trigger teardown is not blocked. ### Precedent * #65740 `EmrServerlessStartJobTrigger` * #65742 `DataprocSubmitTrigger` / `DataprocSubmitJobDirectTrigger` * #66704 `BigQueryInsertJobTrigger` ### Tests Trigger tests cover cancel on kill, the disabled and empty query id no ops, best effort error swallowing, and serialization of the new flag. Operator tests cover the `cancel_on_kill=False` guard and that the flag is threaded into the trigger on defer. Every new assertion fails without the source change. --- ##### Was generative AI tooling used to co-author this PR? - [X] Yes — Claude Code (Fable 5) Generated-by: Claude Code (Fable 5) following [the guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions) -- 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]
