You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2021/07/08 22:47:19 UTC

[GitHub] [superset] john-bodley commented on a change in pull request #15403: feat: cancel db query on stop

john-bodley commented on a change in pull request #15403:
URL: https://github.com/apache/superset/pull/15403#discussion_r666560345



##########
File path: superset/db_engine_specs/base.py
##########
@@ -1304,6 +1304,28 @@ def get_column_spec(
             )
         return None
 
+    @classmethod
+    def get_cancel_query_payload(cls, cursor: Any, query: Query) -> Any:
+        """
+        Returns None if query can not be cancelled.
+        :param cursor: Cursor instance in which the query will be executed
+        :param query: Query instance
+        :return: Type of the payload can vary depends on databases
+        but must be jsonable. None if query can't be cancelled.

Review comment:
       > None if query can't be cancelled
   
   could possibly be implied by better type hints.

##########
File path: superset/db_engine_specs/base.py
##########
@@ -1304,6 +1304,28 @@ def get_column_spec(
             )
         return None
 
+    @classmethod
+    def get_cancel_query_payload(cls, cursor: Any, query: Query) -> Any:
+        """
+        Returns None if query can not be cancelled.

Review comment:
       Could you provide a more descriptive description of what this function does, especially for the non-base case?

##########
File path: superset/db_engine_specs/snowflake.py
##########
@@ -128,3 +129,13 @@ 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_payload(cls, cursor: Any, query: Query) -> Any:
+        cursor.execute("SELECT CURRENT_SESSION()")
+        row = cursor.fetchone()
+        return row[0]
+
+    @classmethod
+    def cancel_query(cls, cursor: Any, query: Query, payload: Any) -> None:
+        cursor.execute("SELECT SYSTEM$CANCEL_ALL_QUERIES(%s)" % payload)

Review comment:
       Could we use a Python 3 format string instead?




-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org