mirror of
https://github.com/apache/superset.git
synced 2026-08-12 11:11:01 +00:00
fix: Make cte_alias a property of db engine spec (#22947)
This commit is contained in:
@@ -86,9 +86,6 @@ ColumnTypeMapping = Tuple[
|
||||
logger = logging.getLogger()
|
||||
|
||||
|
||||
CTE_ALIAS = "__cte"
|
||||
|
||||
|
||||
class TimeGrain(NamedTuple):
|
||||
name: str # TODO: redundant field, remove
|
||||
label: str
|
||||
@@ -346,6 +343,8 @@ class BaseEngineSpec: # pylint: disable=too-many-public-methods
|
||||
# If True, then it will allow in subquery ,
|
||||
# if False it will allow as regular CTE
|
||||
allows_cte_in_subquery = True
|
||||
# Define alias for CTE
|
||||
cte_alias = "__cte"
|
||||
# Whether allow LIMIT clause in the SQL
|
||||
# If True, then the database engine is allowed for LIMIT clause
|
||||
# If False, then the database engine is allowed for TOP clause
|
||||
@@ -889,7 +888,7 @@ class BaseEngineSpec: # pylint: disable=too-many-public-methods
|
||||
|
||||
# extract rest of the SQLs after CTE
|
||||
remainder = "".join(str(token) for token in stmt.tokens[idx:]).strip()
|
||||
return f"WITH {token.value},\n{CTE_ALIAS} AS (\n{remainder}\n)"
|
||||
return f"WITH {token.value},\n{cls.cte_alias} AS (\n{remainder}\n)"
|
||||
|
||||
return None
|
||||
|
||||
|
||||
Reference in New Issue
Block a user