-
Notifications
You must be signed in to change notification settings - Fork 16.3k
Implement on_kill() for SQLExecuteQueryOperator #27514
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -114,6 +114,7 @@ def __init__(self, *args, schema: str | None = None, log_sql: bool = True, **kwa | |
| # Hook deriving from the DBApiHook to still have access to the field in it's constructor | ||
| self.__schema = schema | ||
| self.log_sql = log_sql | ||
| self.running_query_ids: list[str] = [] | ||
|
|
||
| def get_conn(self): | ||
| """Returns a connection object""" | ||
|
|
@@ -244,6 +245,7 @@ def run( | |
| :param return_last: Whether to return result for only last statement or for all after split | ||
| :return: return only result of the ALL SQL expressions if handler was provided. | ||
| """ | ||
| self.running_query_ids = [] | ||
| scalar_return_last = isinstance(sql, str) and return_last | ||
| if isinstance(sql, str): | ||
| if split_statements: | ||
|
|
@@ -264,6 +266,7 @@ def run( | |
| results = [] | ||
| for sql_statement in sql: | ||
| self._run_command(cur, sql_statement, parameters) | ||
| self._update_query_ids(cur) | ||
|
||
|
|
||
| if handler is not None: | ||
| result = handler(cur) | ||
|
|
@@ -294,6 +297,22 @@ def _run_command(self, cur, sql_statement, parameters): | |
| if cur.rowcount >= 0: | ||
| self.log.info("Rows affected: %s", cur.rowcount) | ||
|
|
||
| def _update_query_ids(self, cursor) -> None: | ||
kazanzhy marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| """ | ||
| Adds query ids to list | ||
| :param cur: current cursor after run | ||
| :return: | ||
| """ | ||
| return None | ||
|
|
||
| def kill_query(self, query_id) -> Any: | ||
| """ | ||
| Stops query with certain identifier | ||
| :param query_id: identifier of the query | ||
| :return: | ||
| """ | ||
| raise NotImplementedError | ||
|
|
||
| def set_autocommit(self, conn, autocommit): | ||
| """Sets the autocommit flag on the connection""" | ||
| if not self.supports_autocommit and autocommit: | ||
|
|
||

Uh oh!
There was an error while loading. Please reload this page.