dosubot[bot] commented on issue #29559:
URL: https://github.com/apache/superset/issues/29559#issuecomment-2222256009

   <!-- Greeting -->
   Hey there, @vuongtlt13! 👋 I'm here to assist you with any bugs, questions, 
or contributions. Let's squash those bugs together!
   
   <!-- Answer -->
   The pull request you mentioned introduces the `is_select_query` method and 
uses it within the `is_readonly_query` method to improve performance. This 
change reduces the number of times the `sqlparse.format` function is called, 
which significantly decreases the time required to check if a query is 
read-only.
   
   Here is the relevant code from the pull request:
   
   ```python
   @classmethod
   def is_readonly_query(cls, parsed_query: ParsedQuery) -> bool:
       """
       Pessimistic readonly, 100% sure statement won't mutate anything.
       """
       return KustoKqlEngineSpec.is_select_query(
           parsed_query
       ) or parsed_query.sql.startswith(".show")
   
   @classmethod
   def is_select_query(cls, parsed_query: ParsedQuery) -> bool:
       return not parsed_query.sql.startswith(".")
   ```
   
   This change ensures that the `is_readonly_query` method only calls 
`sqlparse.format` once, reducing the total time from approximately 0.9818s to 
0.3278s 
<sup>[[1]](https://github.com/apache/superset/blob/master/superset/db_engine_specs/kusto.py)</sup>.
   
   Additionally, there are existing unit tests for the `is_readonly_query` 
method that cover various scenarios for both SQL and KQL queries. These tests 
ensure that the method correctly identifies read-only queries 
<sup>[[2]](https://github.com/apache/superset/blob/master/tests/unit_tests/db_engine_specs/test_kusto.py)</sup><sup>[[3]](https://github.com/apache/superset/blob/master/tests/integration_tests/db_engine_specs/base_engine_spec_tests.py)</sup><sup>[[4]](https://github.com/apache/superset/blob/master/tests/integration_tests/db_engine_specs/presto_tests.py)</sup>.
   
   You can review the pull request and run the tests to verify the improvements.
   
   
   <!-- Dosu Comment Footer -->
   *To continue talking to [Dosu](https://dosu.dev), mention @dosu.*
   


-- 
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-unsubscr...@superset.apache.org

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


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

Reply via email to