You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by hu...@apache.org on 2020/10/20 16:33:59 UTC

[incubator-superset] branch hugh/so-495 created (now 641d639)

This is an automated email from the ASF dual-hosted git repository.

hugh pushed a change to branch hugh/so-495
in repository https://gitbox.apache.org/repos/asf/incubator-superset.git.


      at 641d639  split statement by new line then look for explain

This branch includes the following new commits:

     new 641d639  split statement by new line then look for explain

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[incubator-superset] 01/01: split statement by new line then look for explain

Posted by hu...@apache.org.
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 <hu...@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"""