Skip to content

Test that redundant nesting is supported #108

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

Merged
merged 1 commit into from
Jun 9, 2019

Conversation

benesch
Copy link
Contributor

@benesch benesch commented Jun 8, 2019

SELECT * FROM (((SELECT 1))) is just as valid as
SELECT * FROM (SELECT 1). Add a test to ensure that we can parse the
first form.

Addresses a comment from #100.

@benesch benesch requested a review from nickolay June 8, 2019 02:46
@benesch benesch mentioned this pull request Jun 8, 2019
SELECT * FROM (((SELECT 1))) is just as valid as
SELECT * FROM (SELECT 1). Add a test to ensure that we can parse the
first form.

Addresses a comment from apache#100.
@coveralls
Copy link

Pull Request Test Coverage Report for Build 310

  • 16 of 16 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 91.494%

Totals Coverage Status
Change from base Build 307: 0.0%
Covered Lines: 3808
Relevant Lines: 4162

💛 - Coveralls

Copy link
Contributor

@nickolay nickolay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I see: unlike in the spec, TableFactor::NestedJoin can represent a non-join TableFactor in parens, so ((SELECT 1)) gets represented as NestedJoin{ base: Derived(Select...), joins: vec![] }. The spec has separate productions for ((foo NATURAL JOIN bar)) and for FROM ((SELECT 1 a))x, the latter is allowed in <query primary>.

This will probably need to be amended to support queries like (SELECT .. EXCEPT SELECT ..) UNION (SELECT .. EXCEPT SELECT ..), so it's good you took time to add more tests in this PR. Thanks!

(Note that the spec requires naming the derived queries, and MSSQL/Postgres do too, though we currently don't.)

@benesch
Copy link
Contributor Author

benesch commented Jun 8, 2019

Ah, I see: unlike in the spec, TableFactor::NestedJoin can represent a non-join TableFactor in parens, so ((SELECT 1)) gets represented as NestedJoin{ base: Derived(Select...), joins: vec![] }. The spec has separate productions for ((foo NATURAL JOIN bar)) and for FROM ((SELECT 1 a))x, the latter is allowed in <query primary>.

Oh boy. That'll be fun to deal with. 🙃

@benesch benesch merged commit 4a5099f into apache:master Jun 9, 2019
@benesch benesch deleted the test-nesting branch June 21, 2019 22:34
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

Successfully merging this pull request may close these issues.

3 participants