This is an automated email from the ASF dual-hosted git repository.
dpgaspar pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-superset.git
The following commit(s) were added to refs/heads/master by this push:
new 76764ac [sql_lab] Improve performance, only use slow func when needed
(#9612)
76764ac is described below
commit 76764acfc16ef16583dcad30472d93346deaa796
Author: Daniel Vaz Gaspar <[email protected]>
AuthorDate: Thu Apr 23 09:35:57 2020 +0100
[sql_lab] Improve performance, only use slow func when needed (#9612)
---
superset/sql_parse.py | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/superset/sql_parse.py b/superset/sql_parse.py
index 35c6e9f..b39fc44 100644
--- a/superset/sql_parse.py
+++ b/superset/sql_parse.py
@@ -60,12 +60,14 @@ class ParsedQuery:
logger.debug("Parsing with sqlparse statement: %s", self.sql)
self._parsed = sqlparse.parse(self.stripped())
for statement in self._parsed:
- self.__extract_from_token(statement)
self._limit = _extract_limit_from_query(statement)
- self._table_names = self._table_names - self._alias_names
@property
def tables(self) -> Set[str]:
+ if not self._table_names:
+ for statement in self._parsed:
+ self.__extract_from_token(statement)
+ self._table_names = self._table_names - self._alias_names
return self._table_names
@property