mirror of
https://github.com/apache/superset.git
synced 2026-04-18 23:55:00 +00:00
fix: ParsedQuery subselect edge case (#13602)
This commit is contained in:
@@ -21,7 +21,14 @@ from typing import List, Optional, Set
|
||||
from urllib import parse
|
||||
|
||||
import sqlparse
|
||||
from sqlparse.sql import Identifier, IdentifierList, remove_quotes, Token, TokenList
|
||||
from sqlparse.sql import (
|
||||
Identifier,
|
||||
IdentifierList,
|
||||
Parenthesis,
|
||||
remove_quotes,
|
||||
Token,
|
||||
TokenList,
|
||||
)
|
||||
from sqlparse.tokens import Keyword, Name, Punctuation, String, Whitespace
|
||||
from sqlparse.utils import imt
|
||||
|
||||
@@ -278,7 +285,9 @@ class ParsedQuery:
|
||||
table_name_preceding_token = False
|
||||
|
||||
for item in token.tokens:
|
||||
if item.is_group and not self._is_identifier(item):
|
||||
if item.is_group and (
|
||||
not self._is_identifier(item) or isinstance(item.tokens[0], Parenthesis)
|
||||
):
|
||||
self._extract_from_token(item)
|
||||
|
||||
if item.ttype in Keyword and (
|
||||
@@ -291,7 +300,6 @@ class ParsedQuery:
|
||||
if item.ttype in Keyword:
|
||||
table_name_preceding_token = False
|
||||
continue
|
||||
|
||||
if table_name_preceding_token:
|
||||
if isinstance(item, Identifier):
|
||||
self._process_tokenlist(item)
|
||||
|
||||
Reference in New Issue
Block a user