Skip to content

Commit

Permalink
Update connections.py so it doesn’t run anything after its canceled (#…
Browse files Browse the repository at this point in the history
…716)

* Update connections.py so it doesn’t run anything after its canceled
* Update expected cancellation query
* Changelog entry

---------

Co-authored-by: Mike Alfare <[email protected]>
Co-authored-by: Doug Beatty <[email protected]>
  • Loading branch information
3 people authored Aug 5, 2023
1 parent 8423ed0 commit fd28b35
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
6 changes: 6 additions & 0 deletions .changes/unreleased/Fixes-20230804-175222.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
kind: Fixes
body: Cancel all queries when terminating dbt
time: 2023-08-04T17:52:22.956964-06:00
custom:
Author: julio-romero
Issue: "711"
2 changes: 1 addition & 1 deletion dbt/adapters/snowflake/connections.py
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ def cancel(self, connection):

connection_name = connection.name

sql = "select system$abort_session({})".format(sid)
sql = "select system$cancel_all_queries({})".format(sid)

logger.debug("Cancelling query '{}' ({})".format(connection_name, sid))

Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_snowflake_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ def test_cancel_open_connections_single(self):

self.assertEqual(len(list(self.adapter.cancel_open_connections())), 1)

add_query.assert_called_once_with("select system$abort_session(42)")
add_query.assert_called_once_with("select system$cancel_all_queries(42)")

def test_client_session_keep_alive_false_by_default(self):
conn = self.adapter.connections.set_connection_name(name="new_connection_with_new_config")
Expand Down

0 comments on commit fd28b35

Please sign in to comment.