bkyryliuk commented on a change in pull request #11868:
URL:
https://github.com/apache/incubator-superset/pull/11868#discussion_r534560257
##########
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:
@mistercrunch this evaluation happens per statement:
https://github.com/apache/incubator-superset/blob/0409b12a55e893d88f6e992a7df247841a2da8f0/superset/sql_lab.py#L164
Otherwise it will be the same problem for SELECT / EXPLAIN queries
----------------------------------------------------------------
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]