This is an automated email from the ASF dual-hosted git repository. hugh pushed a commit to branch hugh/so-495 in repository https://gitbox.apache.org/repos/asf/incubator-superset.git
commit 641d639e930422b7e0cd7a3c1bc2f9f266543345 Author: hughhhh <hughmi...@gmail.com> AuthorDate: Tue Oct 20 09:32:22 2020 -0700 split statement by new line then look for explain --- superset/sql_parse.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/superset/sql_parse.py b/superset/sql_parse.py index e532a5e..52032d0 100644 --- a/superset/sql_parse.py +++ b/superset/sql_parse.py @@ -89,6 +89,7 @@ class ParsedQuery: logger.debug("Parsing with sqlparse statement: %s", self.sql) self._parsed = sqlparse.parse(self.stripped()) + logger.debug(self._parsed[0]) for statement in self._parsed: self._limit = _extract_limit_from_query(statement) @@ -111,7 +112,11 @@ class ParsedQuery: return self._parsed[0].get_type() == "SELECT" def is_explain(self) -> bool: - return self.stripped().upper().startswith("EXPLAIN") + # Parsing SQL statement for EXPLAIN and filtering out commente + for statement in self.stripped().upper().splitlines(): + if statement.upper().startswith("EXPLAIN"): + return True + return False def is_readonly(self) -> bool: """Pessimistic readonly, 100% sure statement won't mutate anything"""