dcherukumilli commented on issue #32028:
URL: https://github.com/apache/superset/issues/32028#issuecomment-2660296102
We are running into the same kind of issues with CTE's if the postgresql
statements have something like DEPTH SEARCH FIRST. These kind of CTE's worked
in 4.0.1 but they are not working in charts in 4.1.1.
It appears the underlying sqlglot does not support DEPTH SEARCH FIRST in sql
statements.
Here is an example of the SQLGlot issue with the SQL statement. I wonder if
there was a good reason superset moved to sqlglot with all these
incompatibilities.
```
from sqlglot import parse_one
from sqlglot.errors import ParseError
sql = """
WITH RECURSIVE tmp AS (
SELECT uid, lkuid, 0 AS depth, ARRAY[uid, lkuid] AS path, FALSE AS cycle
FROM bs
WHERE uid = 1
UNION ALL
SELECT bs.uid, bs.lkuid, tmp.depth + 1, tmp.path || bs.lkuid, bs.lkuid =
ANY(tmp.path)
FROM bs, tmp
WHERE bs.uid = tmp.lkuid
AND NOT bs.lkuid = ANY(tmp.path)
)
SEARCH DEPTH FIRST BY uid SET ordercol
SELECT * FROM tmp ORDER BY ordercol;
"""
try:
parsed_statement = parse_one(sql, read="postgres")
if parsed_statement:
print("SQLGlot successfully parsed the PostgreSQL statement.")
# Optional: Print the parsed statement in PostgreSQL dialect (pretty
format)
# print(parsed_statement.sql(dialect="postgres", pretty=True))
else:
print("SQLGlot failed to parse the PostgreSQL statement (returned
None).")
except ParseError as e:
print(f"SQLGlot ParseError: {e}")
```
--
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]