rusackas commented on code in PR #44552:
URL: https://github.com/apache/superset/pull/44552#discussion_r4134615056
##########
superset/common/query_context_processor.py:
##########
@@ -305,7 +306,15 @@ def get_df_payload_result(
)
)
- query_result = self.get_query_result(query_obj)
+ # Make the warehouse query cancellable by its owner for the
span
+ # of its execution, so Explore's Stop button kills the query
+ # rather than just abandoning the response. No-op for engines
+ # without cancel support, and for requests carrying no
client_id.
+ with cancellable_chart_query(
Review Comment:
Async does not need this registry. `_capture_query_cancellation` in
`async_queries.py` gives the worker task its own abort-triggered cancel, wired
to `ctx.on_abort`, independent of `client_id` or serialization. This registry
only backs the synchronous Stop path.
##########
superset/charts/data/api.py:
##########
@@ -345,6 +360,63 @@ def data( # noqa: C901
expected_rows=expected_rows,
)
+ @expose("/data/stop", methods=("POST",))
+ @protect()
+ @statsd_metrics
+ @event_logger.log_this_with_context(
+ action=lambda self, *args, **kwargs:
f"{self.__class__.__name__}.stop_data",
+ log_to_statsd=False,
+ )
+ def stop_data(self) -> Response:
+ """
+ Cancel a running chart-data query.
+ ---
+ post:
+ summary: Cancel a running chart-data query
+ description: >-
+ Cancels the warehouse query started by a chart-data request that
+ carried the given `client_id`, for databases whose engine supports
+ query cancellation. The `client_id` is resolved only within the
+ requesting user's own in-flight queries, so it cannot be used to
+ reach another user's query.
+ requestBody:
+ required: true
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/ChartDataStopSchema'
+ responses:
+ 200:
+ description: Cancellation outcome
+ content:
+ application/json:
+ schema:
+ type: object
+ properties:
+ result:
+ type: object
+ properties:
+ stopped:
+ type: boolean
+ description: >-
+ Whether the engine reported the query cancelled.
+ False when there was no such in-flight query for
+ this user, or the engine could not cancel it.
+ 400:
+ $ref: '#/components/responses/400'
+ 401:
+ $ref: '#/components/responses/401'
+ 500:
Review Comment:
Added the 403 response here, same as `data`'s spec since `stop_data` is
gated by the identical `can_read` check.
--
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]