DG47 commented on code in PR #74279:
URL: https://github.com/apache/airflow/pull/74279#discussion_r4668838722


##########
providers/common/sql/src/airflow/providers/common/sql/operators/sql.py:
##########
@@ -546,6 +552,7 @@ def __init__(
         self.return_last = return_last
         self.show_return_value_in_logs = show_return_value_in_logs
         self.requires_result_fetch = requires_result_fetch
+        self.cancel_on_kill = cancel_on_kill

Review Comment:
   Done in 368d447284: `SnowflakeSqlApiOperator` now passes 
`cancel_on_kill=cancel_on_kill` to `super().__init__`. 
`test_snowflake_sql_api_on_kill_respects_cancel_on_kill_false` failed on the 
branch before this commit and passes with it, and I ran the full 
`providers/snowflake/tests/unit/snowflake/operators/test_snowflake.py` locally 
(all passing).



##########
providers/common/sql/src/airflow/providers/common/sql/hooks/sql.py:
##########
@@ -197,6 +203,11 @@ def __init__(self, *args, schema: str | None = None, 
log_sql: bool = True, **kwa
         self.__schema = schema
         self.log_sql = log_sql
         self.descriptions: list[Sequence[Sequence] | None] = []
+        # The cursor whose statement is running right now (set by 
``_track_running_cursor``), used by
+        # ``cancel_query``
+        self._running_cursor: Any = None
+        # Whether ``_track_running_cursor`` cancels a statement interrupted by 
a timeout or keyboard interrupt
+        self.cancel_on_interrupt = True

Review Comment:
   Done in 37a226d385: went with option 1. `DbApiHook.cancel_on_interrupt` now 
defaults to `False`, so `run()` callers other than `SQLExecuteQueryOperator` 
(check operators, `SqlSensor`, `GenericTransfer`, user code) keep leaving an 
interrupted statement running. `SQLExecuteQueryOperator.execute()` still sets 
it from `cancel_on_kill` (default `True`), so the operator behaves as before. 
The hook tests that cover the timeout cancel now opt in explicitly, 
`test_statement_is_not_cancelled_on_timeout_by_default` pins the new default, 
and the operator timeout test asserts the hook starts at `False`. The class 
docstring, `_track_running_cursor` docstring, `operators.rst` and the PR 
description now say that only `SQLExecuteQueryOperator` turns it on. The other 
operators can be switched on in follow-ups, each with its own `cancel_on_kill` 
and `on_kill`.



-- 
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