Skip to content

feat: Add support for MSSQL table options #1414

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 4 commits into from
Sep 11, 2024

Conversation

bombsimon
Copy link
Contributor

Currently table options only supports key value-pairs where the key is an Ident and the value is an Expr. In MSSQL the WITH options can be more complex than that, configuring storage, partitioning and more.

This implements the SQL Server CREATE TABLE syntax extending SqlOptions to be an enum with more complex values.

@coveralls
Copy link

coveralls commented Sep 6, 2024

Pull Request Test Coverage Report for Build 10800832175

Details

  • 287 of 310 (92.58%) changed or added relevant lines in 6 files are covered.
  • 15 unchanged lines in 3 files lost coverage.
  • Overall coverage increased (+0.02%) to 89.329%

Changes Missing Coverage Covered Lines Changed/Added Lines %
tests/sqlparser_common.rs 22 23 95.65%
src/ast/mod.rs 21 24 87.5%
src/parser/mod.rs 57 64 89.06%
tests/sqlparser_mssql.rs 163 175 93.14%
Files with Coverage Reduction New Missed Lines %
tests/sqlparser_common.rs 1 89.77%
tests/sqlparser_bigquery.rs 1 90.32%
src/ast/mod.rs 13 82.36%
Totals Coverage Status
Change from base Build 10799975777: 0.02%
Covered Lines: 29426
Relevant Lines: 32941

💛 - Coveralls

- Rename T-SQL to MSSQL in docs
- Add examples and links to all `SqlOption`
- Remove duplicate `parse_options` function
- Avoid nested if/else chains
- Rename field of `SqlOption::KeyValue` to `key`
- Extend testing with function calls, negative tests and using
  `verified_stmt`
- Move parsing of `ASC`|`DESC` to function
@bombsimon bombsimon changed the title feat: Add support for T-SQL table options feat: Add support for MSSQL table options Sep 9, 2024
@bombsimon bombsimon requested a review from iffyio September 9, 2024 07:38
let asc = if self.parse_keyword(Keyword::ASC) {
/// Parsae ASC or DESC, returns an Option with true if ASC, false of DESC or `None` if none of
/// them.
pub fn parse_asc(&mut self) -> Option<bool> {
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe this can be more generic in naming like parse_asc_desc or parse_sort_direction etc? thinking since asc itself isnt the only thing being parsed as the name currently suggests

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since it was used to only represent if asc (true/false) I wanted to use something like is_asc but I found zero examples of is_ prefixed methods so stuck to parse. I think parse_asc_desc is fine but it's a bit confusing that it doesn't return an enum or either of them but a boolean. Hopefully the description is good enough, I opted to use parse_asc_desc!

Copy link
Contributor

@iffyio iffyio left a comment

Choose a reason for hiding this comment

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

LGTM! cc @alamb

Copy link
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

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

Thank you very much @bombsimon and @iffyio -- this looks really nice.

It is so great to get pinged on a PR that is just ready to go. 🚀

@alamb alamb merged commit b9e7754 into apache:main Sep 11, 2024
10 checks passed
@bombsimon bombsimon deleted the clustered-index branch September 11, 2024 20:42
ayman-sigma pushed a commit to sigmacomputing/sqlparser-rs that referenced this pull request Nov 19, 2024
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.

4 participants