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

Wrong AST for JOINs #730

Closed
johnedquinn opened this issue Aug 30, 2022 · 1 comment
Closed

Wrong AST for JOINs #730

johnedquinn opened this issue Aug 30, 2022 · 1 comment
Labels
bug Something isn't working

Comments

@johnedquinn
Copy link
Member

Description

In the process of replacing SqlParser with a parser generated by ANTLR, I came across a weird conditional in the implementation of SqlParser:

See this code block. It references the RHS of a JOIN, when the RHS is a PAREN. It makes a weird check about literals a SELECT.

Anyways, I actually believe that this check is wrong -- and therefore, these tests are also wrong.

Test No. 1 (SqlParserJoinTest > selectThreeJoinsSpecifiedOrderParensTest)

Input query:

SELECT x FROM A INNER JOIN (B INNER JOIN (C INNER JOIN D ON C = D) ON B = C) ON A = B

Expected result:

    (select
        (project
            (project_list
                (project_expr
                    (id x (case_insensitive) (unqualified))
                    null)))
        (from
            (join
                (inner)
                (join
                    (inner)
                    (join
                        (inner)
                        (scan
                            (id C (case_insensitive) (unqualified))
                            null
                            null
                            null)
                        (scan
                            (id D (case_insensitive) (unqualified))
                            null
                            null
                            null)
                        (eq
                            (id C (case_insensitive) (unqualified))
                            (id D (case_insensitive) (unqualified))))
                    (scan
                        (id B (case_insensitive) (unqualified))
                        null
                        null
                        null)
                    (eq
                        (id B (case_insensitive) (unqualified))
                        (id C (case_insensitive) (unqualified))))
                (scan
                    (id A (case_insensitive) (unqualified))
                    null
                    null
                    null)
                (eq
                    (id A (case_insensitive) (unqualified))
                    (id B (case_insensitive) (unqualified))))))

What I expected:

    (select
        (project
            (project_list
                (project_expr
                    (id x (case_insensitive) (unqualified))
                    null)))
        (from
            (join
                (inner)
                (scan
                    (id A (case_insensitive) (unqualified))
                    null
                    null
                    null)
                (join
                    (inner)
                    (scan
                        (id B (case_insensitive) (unqualified))
                        null
                        null
                        null)
                    (join
                        (inner)
                        (scan
                            (id C (case_insensitive) (unqualified))
                            null
                            null
                            null)
                        (scan
                            (id D (case_insensitive) (unqualified))
                            null
                            null
                            null)
                        (eq
                            (id C (case_insensitive) (unqualified))
                            (id D (case_insensitive) (unqualified))))
                    (eq
                        (id B (case_insensitive) (unqualified))
                        (id C (case_insensitive) (unqualified))))
                (eq
                    (id A (case_insensitive) (unqualified))
                    (id B (case_insensitive) (unqualified))))))

Other Tests

The other test that is wrong is: SqlParserJoinTest > selectTwoJoinsSpecifiedOrderParensTest.

Action Items

The test cases should be updated. This will be fixed in PartiQLParser by the upcoming parser merge.

@johnedquinn johnedquinn added the bug Something isn't working label Aug 30, 2022
@johnedquinn
Copy link
Member Author

Closed by #711

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant