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

Parsing nested joins without parenthesis #1878

Closed
10bas10 opened this issue Jul 3, 2023 · 6 comments
Closed

Parsing nested joins without parenthesis #1878

10bas10 opened this issue Jul 3, 2023 · 6 comments

Comments

@10bas10
Copy link
Contributor

10bas10 commented Jul 3, 2023

By applying the nested join you are able to LEFT JOIN a combined set where an INNER JOIN is applied. However the last ON syntax isnt parsed properly:

import sqlglot
from sqlglot import optimizer
expr = sqlglot.parse_one("""
SELECT
 a.id
,b.test
,c.test2
FROM a
LEFT JOIN
    b
    INNER JOIN c
        ON c.id = b.id
    ON b.id = a.id
""", read="tsql")

Resulting in an error:

ParseError: Invalid expression / Unexpected token. Line 11, Col: 6.
@tobymao
Copy link
Owner

tobymao commented Jul 3, 2023

i believe this is a duplicate. @georgesittas if this is too difficult to do, let's close it as not planned. i believe i did that the last time this was filed

@tobymao
Copy link
Owner

tobymao commented Jul 3, 2023

i can't find the old issue, but i'm going to close this again as not planned.

@tobymao tobymao closed this as not planned Won't fix, can't repro, duplicate, stale Jul 3, 2023
@10bas10
Copy link
Contributor Author

10bas10 commented Jul 3, 2023

What does "not planned" mean?

@georgesittas
Copy link
Collaborator

georgesittas commented Jul 3, 2023

@tobymao in order to handle this, I think we'd need to make _parse_join recursive so that each ON clause is matched with the corresponding join. I'm not sure if it'll be so easy, though (e.g. what changes need to be made in the optimizer?).

@tobymao
Copy link
Owner

tobymao commented Jul 3, 2023

What does "not planned" mean?

it means we’re not committing to doing this.

we may if it’s easy

@tobymao
Copy link
Owner

tobymao commented Jul 3, 2023

i have a fix for this coming soon

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

3 participants