diff --git a/superset/sql_parse.py b/superset/sql_parse.py index 3e5038676513..d87db833eaa6 100644 --- a/superset/sql_parse.py +++ b/superset/sql_parse.py @@ -208,7 +208,13 @@ def _extract_from_token( # pylint: disable=too-many-branches self, token: Token ) -> None: """ - Populate self._tables from token + store a list of subtokens and store lists of + subtoken list. + + It extracts and from :param token: and loops + through all subtokens recursively. It finds table_name_preceding_token and + passes and to self._process_tokenlist to populate + self._tables. :param token: instance of Token or child class, e.g. TokenList, to be processed """ @@ -240,9 +246,8 @@ def _extract_from_token( # pylint: disable=too-many-branches if isinstance(token2, TokenList): self._process_tokenlist(token2) elif isinstance(item, IdentifierList): - for token2 in item.tokens: - if not self._is_identifier(token2): - self._extract_from_token(item) + if any(not self._is_identifier(token2) for token2 in item.tokens): + self._extract_from_token(item) def set_or_update_query_limit(self, new_limit: int) -> str: """Returns the query with the specified limit.