sadpandajoe commented on code in PR #43942:
URL: https://github.com/apache/superset/pull/43942#discussion_r3946380257


##########
UPDATING.md:
##########
@@ -24,6 +24,16 @@ assists people when migrating to a new version.
 
 ## Next
 
+### SQL Lab query execution re-platformed onto the Global Task Framework 
(breaking)
+
+SQL Lab no longer runs queries on its own bespoke Celery task. Query execution 
now goes through the unified SQL execution feature (`superset/sql/execution/`): 
synchronous requests run it inline, and **asynchronous** requests run it as a 
Global Task Framework (GTF) task (`superset.sql_lab`, one task per query). As a 
result an executing async SQL Lab statement appears in the Task List and is 
cancellable from there, and stopping a query (SQL Lab's Stop button / `POST 
/api/v1/query/stop`) routes through the native GTF cancel.
+
+Breaking changes (no deprecation window):
+
+- **Async SQL Lab execution now requires the `GLOBAL_TASK_FRAMEWORK` feature 
flag.** With it disabled, a request that asks to run asynchronously returns a 
clear error rather than executing; synchronous execution is unaffected and 
needs no feature flag. (Async also continues to require a configured 
`RESULTS_BACKEND` and Celery workers, as before.)

Review Comment:
   The existing Celery guide still tells operators to import 
`superset.sql_lab`, configure `sql_lab.get_sql_results`, and enable only the 
database setting. After this change those deployments retain a removed task 
configuration or get the GTF-disabled error; could the guide be updated in this 
PR?



##########
superset/daos/query.py:
##########
@@ -78,6 +78,25 @@ def stop_query(client_id: str) -> None:
             )
             return
 
+        # An async query runs as a GTF task (superset.sql_lab, keyed by 
client_id).
+        # Cancel through GTF so stopping from SQL Lab and from the Task List 
view are
+        # the same operation: the task's abort handler kills the warehouse 
query and
+        # the task mirrors STOPPED onto the Query row.
+        from superset.commands.tasks.cancel import CancelTaskCommand
+        from superset.daos.tasks import TaskDAO
+        from superset.tasks.sql_queries import SQL_LAB_TASK
+
+        user_id = get_user_id()
+        task = (
+            TaskDAO.find_by_task_key(SQL_LAB_TASK, client_id, "private", 
user_id)
+            if user_id is not None
+            else None
+        )
+        if task is not None:
+            CancelTaskCommand(task.uuid).run()
+            return

Review Comment:
   Agreed—the PENDING-to-ABORTED path has no worker execution to call 
`_mirror_terminal_status`, so the Query stays PENDING and clients continue 
polling it. Could this cancellation path mark the associated Query STOPPED as 
well?



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

Reply via email to