mistercrunch commented on a change in pull request #11868:
URL: 
https://github.com/apache/incubator-superset/pull/11868#discussion_r534539187



##########
File path: superset/sql_parse.py
##########
@@ -119,12 +119,28 @@ def is_explain(self) -> bool:
         # Explain statements will only be the first statement
         return statements_without_comments.startswith("EXPLAIN")
 
+    def is_show(self) -> bool:
+        # Remove comments
+        statements_without_comments = sqlparse.format(
+            self.stripped(), strip_comments=True
+        )
+        # Show statements will only be the first statement
+        return statements_without_comments.upper().startswith("SHOW")
+
+    def is_set(self) -> bool:
+        # Remove comments
+        statements_without_comments = sqlparse.format(
+            self.stripped(), strip_comments=True
+        )
+        # Set statements will only be the first statement
+        return statements_without_comments.upper().startswith("SET")
+
     def is_unknown(self) -> bool:
         return self._parsed[0].get_type() == "UNKNOWN"
 
     def is_readonly(self) -> bool:
         """Pessimistic readonly, 100% sure statement won't mutate anything"""
-        return self.is_select() or self.is_explain()
+        return self.is_select() or self.is_explain() or self.is_set() or 
self.is_show()

Review comment:
       I'm curious reading this (would have been an issue before this PR) on 
whether running multiple statements including non-readonly would work well 
here, as in:
   ```sql
   SET foo='bar';
   UPDATE {...}
   ```




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

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