You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
raw = """
SELECT
TO_CHAR(ROUTING_ID) AS ROUTING_ID,
SUBSTR(PFAD, 4) AS PFAD
FROM
(
SELECT ROUTING_ID, SYS_CONNECT_BY_PATH(TEXT,' > ') AS PFAD
FROM BUSINESSOBJECTS.BO_SYS_BREADCRUMB_S_DVB_HUB
START WITH NVL(PARENT, 0) = 0
CONNECT BY PRIOR ID = PARENT
)
"""
for table in parse_one(raw, read="snowflake", error_level=ErrorLevel.IMMEDIATE).find_all(exp.Table):
print(table)`
Error:
sqlglot.errors.ParseError: Expecting ). Line 9, Col: 12.
_PATH(TEXT,' > ') AS PFAD
FROM BUSINESSOBJECTS.BO_SYS_BREADCRUMB_S_DVB_HUB
START WITH NVL(PARENT, 0) = 0
CONNECT BY PRIOR ID = PARENT
)
Thanks so much for this! Upgrading from 17.8.6 to 18.5.1 seems to have solved the START WITH / CONNECT BY problem for me parsing Snowflake queries too.
Snowflake dialect does not know about CONNECT BY
Fully reproducible code snippet
`from sqlglot import Dialects, parse_one, exp
from sqlglot.errors import ErrorLevel
raw = """
SELECT
TO_CHAR(ROUTING_ID) AS ROUTING_ID,
SUBSTR(PFAD, 4) AS PFAD
FROM
(
SELECT ROUTING_ID, SYS_CONNECT_BY_PATH(TEXT,' > ') AS PFAD
FROM BUSINESSOBJECTS.BO_SYS_BREADCRUMB_S_DVB_HUB
START WITH NVL(PARENT, 0) = 0
CONNECT BY PRIOR ID = PARENT
)
"""
for table in parse_one(raw, read="snowflake", error_level=ErrorLevel.IMMEDIATE).find_all(exp.Table):
print(table)`
Error:
sqlglot.errors.ParseError: Expecting ). Line 9, Col: 12.
_PATH(TEXT,' > ') AS PFAD
FROM BUSINESSOBJECTS.BO_SYS_BREADCRUMB_S_DVB_HUB
START WITH NVL(PARENT, 0) = 0
CONNECT BY PRIOR ID = PARENT
)
Official Documentation
https://docs.snowflake.com/en/sql-reference/constructs/connect-by
The text was updated successfully, but these errors were encountered: