eschutho commented on issue #17011:
URL: https://github.com/apache/superset/issues/17011#issuecomment-1176794144

   So this is the flow for the whole flow of running a query to stopping it. It 
should work with Athena as long as we build out the two required methods 
`cancel_query` and `get_cancel_query_id` for Athena in the db engine spec: 
   
   ```
   with closing(engine.raw_connection()) as conn:
           # get cursor
           cursor = conn.cursor() 
   
           # fetch cancel query id from  cursor
           cancel_query_id = db_engine_spec.get_cancel_query_id(cursor, query)
   
          # save cursor in metadata on query model
            if cancel_query_id is not None:
               query.set_extra_json_key(cancel_query_key, cancel_query_id)
               session.commit()
   
          ...
          # execute statement (thread is blocked)
                   result_set = execute_sql_statement(
                       statement,
                       query,
                       session,
                       cursor,
                       log_params,
                       apply_ctas,
                   )
   ```
   
   (separate thread after clicking the "STOP" button)
   ```
       @expose("/stop_query/", methods=["POST"])
       ...
       # fetch cancel_query_key from query model metadata
       cancel_query_id = query.extra.get(cancel_query_key)
   
       .....
       # pass the cancel_query_id to the db_engine_spec and cancel the query
               return query.database.db_engine_spec.cancel_query(
                   cursor, query, cancel_query_id
               )
   ```
   
   
   


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