Skip to content

Support nested joins #100

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 8, 2019
Merged

Support nested joins #100

merged 1 commit into from
Jun 8, 2019

Conversation

benesch
Copy link
Contributor

@benesch benesch commented Jun 3, 2019

Fix #83.

@nickolay this is everything, for the moment! Feel free to review/merge in any order. I'll take care of rebasing whatever winds up conflicting (though feel free to rebase yourself, if you're so inclined).

@benesch benesch requested a review from nickolay June 3, 2019 05:08
@coveralls
Copy link

coveralls commented Jun 3, 2019

Pull Request Test Coverage Report for Build 290

  • 54 of 57 (94.74%) changed or added relevant lines in 3 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.03%) to 91.512%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/sqlparser.rs 18 19 94.74%
tests/sqlparser_common.rs 28 30 93.33%
Totals Coverage Status
Change from base Build 287: 0.03%
Covered Lines: 3795
Relevant Lines: 4147

💛 - 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.

I thought fixing this would have to deal with the weird way we store joins, with FROM foo NATURAL JOIN bar, baz NATURAL JOIN qux stored as vec![Natural "bar", Implicit "baz", Natural "qux"] instead of From [Natural ("foo", "bar"), Natural("baz", "qux")].

But as I realized just now, this is an unrelated uncontroversial change: adding support for the <parenthesized joined table> variant defined in the spec.

This doesn't handle ((a NATURAL JOIN b)) just as we didn't handle ((SELECT ..)) derived tables, which I think is OK.

LGTM, thanks!

@benesch
Copy link
Contributor Author

benesch commented Jun 8, 2019

I thought fixing this would have to deal with the weird way we store joins, with FROM foo NATURAL JOIN bar, baz NATURAL JOIN qux stored as vec![Natural "bar", Implicit "baz", Natural "qux"] instead of From [Natural ("foo", "bar"), Natural("baz", "qux")].

Oh wow, that is some headscratching syntax. I've never seen anyone combine the implicit and explicit syntaxes before! I wasn't even aware that was possible. Sigh.

This doesn't handle ((a NATURAL JOIN b)) just as we didn't handle ((SELECT ..)) derived tables, which I think is OK.

Oh, good catch. I'm going to merge for now, but I'll investigate making a follow-on PR to support double parens.

@benesch benesch merged commit 5f9f17d into apache:master Jun 8, 2019
@benesch benesch deleted the nested-joins branch June 8, 2019 02:37
benesch added a commit to benesch/sqlparser-rs that referenced 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.
@benesch
Copy link
Contributor Author

benesch commented Jun 8, 2019

This doesn't handle ((a NATURAL JOIN b)) just as we didn't handle ((SELECT ..)) derived tables, which I think is OK.

Oh, good catch. I'm going to merge for now, but I'll investigate making a follow-on PR to support double parens.

Wait... I think we do support this! Unless I'm misunderstanding. See #108.

@benesch
Copy link
Contributor Author

benesch commented Jun 8, 2019

I thought fixing this would have to deal with the weird way we store joins, with FROM foo NATURAL JOIN bar, baz NATURAL JOIN qux stored as vec![Natural "bar", Implicit "baz", Natural "qux"] instead of From [Natural ("foo", "bar"), Natural("baz", "qux")].

Oh wow, that is some headscratching syntax. I've never seen anyone combine the implicit and explicit syntaxes before! I wasn't even aware that was possible. Sigh.

I took a stab at fixing this in #109. Discussion to follow there.

benesch added a commit to benesch/sqlparser-rs that referenced 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.
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.

Support join associativity
3 participants