betodealmeida commented on code in PR #33518:
URL: https://github.com/apache/superset/pull/33518#discussion_r2096041661
##########
superset/db_engine_specs/base.py:
##########
@@ -1124,18 +1128,9 @@ def get_cte_query(cls, sql: str) -> str | None:
"""
if not cls.allows_cte_in_subquery:
- stmt = sqlparse.parse(sql)[0]
-
- # The first meaningful token for CTE will be with WITH
- idx, token = stmt.token_next(-1, skip_ws=True, skip_cm=True)
- if not (token and token.ttype == CTE):
- return None
- idx, token = stmt.token_next(idx)
- idx = stmt.token_index(token) + 1
-
- # extract rest of the SQLs after CTE
- remainder = "".join(str(token) for token in
stmt.tokens[idx:]).strip()
- return f"WITH {token.value},\n{cls.cte_alias} AS (\n{remainder}\n)"
+ statement = SQLStatement(sql, engine=cls.engine)
+ if statement.has_cte():
+ return statement.as_cte(cls.cte_alias).format()
Review Comment:
Nope, this will be valid.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]