Skip to content

Support arbitrary WITH options for CREATE [TABLE|VIEW] #74

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 3, 2019

Conversation

benesch
Copy link
Contributor

@benesch benesch commented May 22, 2019

Both Postgres and MSSQL accept this syntax, though the particular
options they accept differ.

@coveralls
Copy link

coveralls commented May 22, 2019

Pull Request Test Coverage Report for Build 273

  • 94 of 98 (95.92%) changed or added relevant lines in 4 files are covered.
  • 1 unchanged line in 1 file lost coverage.
  • Overall coverage increased (+0.1%) to 90.832%

Changes Missing Coverage Covered Lines Changed/Added Lines %
tests/sqlparser_common.rs 36 40 90.0%
Files with Coverage Reduction New Missed Lines %
src/sqlparser.rs 1 91.26%
Totals Coverage Status
Change from base Build 267: 0.1%
Covered Lines: 3537
Relevant Lines: 3894

💛 - Coveralls

@benesch benesch mentioned this pull request May 22, 2019
@nickolay
Copy link
Contributor

I'd like to share a few thoughts on this, even though I don't have specific suggestions at this time:

  • Both Postgres and MS support options without values (e.g. Postgres CREATE TABLE .. WITH (OIDS)). (MS additionally does not wrap the CREATE VIEW options in parentheses.)
  • There's a standard WITH .. CHECK OPTION clause, distinct from the "WITH options" this PR implements, which makes for two sets of "with options"...
  • If we want to support parsing statements that are not ;-delimited, care should be taken to distinguish WITH (options) at the end of a CREATE statement and a WITH cte AS at the beginning of the next query.

Some links to documentation (apparently these options can appear in other contexts, this is just a sample):

@nickolay
Copy link
Contributor

nickolay commented Jun 2, 2019

One thing I'd like to request is that you put a realistic SQL in the testcase (possibly moving it to a dialect-specific suite); the extensions can be implemented in a follow-up.

My idea with sqlparser_common.rs was that it runs (and must succeed) for all dialects. While currently only the lexer does dialect-specific processing, I imagine we'll come to a point where different dialects must parse a given SQL differently. I hoped that being clear about which dialect is supposed to handle certain non-common testcases would make that easier.

@benesch benesch force-pushed the with-options branch 3 times, most recently from 9922cc5 to e9cdc81 Compare June 3, 2019 17:10
Both Postgres and MSSQL accept this syntax, though the particular
options they accept differ.
@benesch
Copy link
Contributor Author

benesch commented Jun 3, 2019

Ok, added a more realistic test case to the Postgres dialect. Thanks for the review!

@benesch benesch merged commit 6fceba8 into apache:master Jun 3, 2019
@benesch benesch deleted the with-options branch June 3, 2019 18:00
@nickolay
Copy link
Contributor

nickolay commented Jun 3, 2019

Thanks! Given that you kept WITH (foo = 'bar', a = 123) in the "general" tests I'd like to clarify - do you rely on a variation of this in your product?

@benesch
Copy link
Contributor Author

benesch commented Jun 4, 2019

do you rely on a variation of this in your product?

We do, yeah—but I think we'd be happy to declare that we are most closely aligned with the Postgres dialect, and ask for that dialect when we parse. I.e., you should definitely feel free to delete the general test case, or move it to the Postgres-specific test case.

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