koszti commented on a change in pull request #15403:
URL: https://github.com/apache/superset/pull/15403#discussion_r673802800
##########
File path: superset/db_engine_specs/snowflake.py
##########
@@ -128,3 +129,34 @@ def mutate_db_for_connection_test(database: "Database") ->
None:
engine_params["connect_args"] = connect_args
extra["engine_params"] = engine_params
database.extra = json.dumps(extra)
+
+ @classmethod
+ def get_cancel_query_id(cls, cursor: Any, query: Query) -> Optional[str]:
+ """
+ Get Snowflake session ID that will be used to cancel all other running
+ queries in the same session.
+
+ :param cursor: Cursor instance in which the query will be executed
+ :param query: Query instance
+ :return: Snowflake Session ID
+ """
+ cursor.execute("SELECT CURRENT_SESSION()")
Review comment:
The query that you're referring to is running when the query initiated
and not when the stop button pressed.
It's using the same cursor that is created in the first place in
`execute_sql_statements`
[here](https://github.com/koszti/superset/blob/517c7928dfee2412b96836957a2efd2b5953c1e5/superset/sql_lab.py#L452).
The returned session id then saved into `query` table in the superset backend
database.
When the stop button pressed, we get the saved session id from the `query`
table and kill it and kill the query by another SQL. In this way queries can be
killed at a later from every celery worker.
It's tested on Postgres, MySQL and Snowflake engines with sync and async
query mode.
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]