Skip to content

Support column names in more places #98

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 2 commits into from
Jun 4, 2019
Merged

Conversation

benesch
Copy link
Contributor

@benesch benesch commented Jun 3, 2019

See individual commits for details.

@benesch benesch requested a review from nickolay June 3, 2019 04:36
@coveralls
Copy link

Pull Request Test Coverage Report for Build 251

  • 60 of 64 (93.75%) changed or added relevant lines in 4 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 90.127%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/sqlparser.rs 11 13 84.62%
tests/sqlparser_common.rs 30 32 93.75%
Totals Coverage Status
Change from base Build 234: 0.0%
Covered Lines: 3396
Relevant Lines: 3768

💛 - Coveralls

1 similar comment
@coveralls
Copy link

Pull Request Test Coverage Report for Build 251

  • 60 of 64 (93.75%) changed or added relevant lines in 4 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 90.127%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/sqlparser.rs 11 13 84.62%
tests/sqlparser_common.rs 30 32 93.75%
Totals Coverage Status
Change from base Build 234: 0.0%
Covered Lines: 3396
Relevant Lines: 3768

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

LGTM! I'm inclined to rename Cte::renamed_columns to columns and move it before the query to match the style of this PR once you finish landing your patches.

I'm always unsure if I want to introduce a new struct vs tolerate some duplication in existing structs, so if you have a couple of words to say about why you chose to extract TableAlias, I'd appreciate it. Note that I don't have anything against it, so just merging is fine as well.

(Ouch, this probably conflicts with the recently landed "WITH options" PR -- the expected order in CREATE VIEW is view_name (columns, list) WITH (options) AS I think? Having dealt with merge conflicts a lot, I feel your pain - thanks for doing this again! and if I can make this easier, please let me know.)

benesch added 2 commits June 3, 2019 23:50
A `CREATE VIEW` statement may provide names for its columns that
override the names of the columns derived from the view's query.
A table alias can specify new names for the columns within the aliased
table, in addition to a new name for the table itself.
@benesch
Copy link
Contributor Author

benesch commented Jun 4, 2019

I'm always unsure if I want to introduce a new struct vs tolerate some duplication in existing structs, so if you have a couple of words to say about why you chose to extract TableAlias, I'd appreciate it. Note that I don't have anything against it, so just merging is fine as well.

Sure thing! I thought having a separate struct that could be wrapped in an Option better communicated the set of possibilities. That is, sticking both a table_alias and a column_aliases field in the outer struct, like

struct Table {
    table_alias: Option<SQLObjectName>,
    column_aliases: Vec<SQLIdentifier>
}

indicates that it might be valid to have column aliases without a table alias, when it is not in fact valid. (You can specify a table alias without specifying column aliases, but you cannot specify a column alias without specifying a table alias.)

(Ouch, this probably conflicts with the recently landed "WITH options" PR -- the expected order in CREATE VIEW is view_name (columns, list) WITH (options) AS I think? Having dealt with merge conflicts a lot, I feel your pain - thanks for doing this again! and if I can make this easier, please let me know.)

No problem! The rebase is in, and the conflicts weren't too bad. I really appreciate the speed with which you're moving through these PRs, and I'm happy to do a bit of work to split and reintegrate these changes to make the review easier. In other words, it's the overall rate of divergence that's scary and time-consuming, not the latency of any individual review, and the rate of divergence is very solidly negative at the moment! :)

@benesch benesch merged commit 4c27222 into apache:master Jun 4, 2019
@benesch benesch deleted the col-names branch June 4, 2019 04:00
@nickolay
Copy link
Contributor

nickolay commented Jun 4, 2019

You can specify a table alias without specifying column aliases, but you cannot specify a column alias without specifying a table alias.

Ah, I have not thought of this. Thanks for clarifying - this makes perfect sense to me.

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