Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Snowflake START WITH ... CONNECT BY syntax not recognized #2112

Closed
tglunde opened this issue Aug 25, 2023 · 2 comments
Closed

Snowflake START WITH ... CONNECT BY syntax not recognized #2112

tglunde opened this issue Aug 25, 2023 · 2 comments

Comments

@tglunde
Copy link

tglunde commented Aug 25, 2023

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

@tglunde
Copy link
Author

tglunde commented Aug 26, 2023

@tobymao thx a lot for the quick reaction :-)

@mro-msandford
Copy link

mro-msandford commented Sep 18, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants