Skip to content

Create table builder structure #659

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
Oct 7, 2022
Merged

Create table builder structure #659

merged 2 commits into from
Oct 7, 2022

Conversation

AugustoFKL
Copy link
Contributor

Proposal of usage of a CreateTableBuilder structure, instead of the pure create table that we've been using right now.

This has 2 benefits:

  • We can reduce calls anywhere the statement isn't meant to be "complete", i.e., when some parts are certain to be a default value.
  • Callers can switch between the current statement to this structure, so they don't need to move an enum, a struct instead.

@alamb @nickolay what do you think?

I know this resembles #315 (comment) but, instead of replacing our current API, we can give the upstream the possibility of creating the struct, moving it with more ease around the code. If you think that's OK, I'll add a TryFrom<Statement> for this (or maybe just a convert method), and expand that going from the biggest statement to the smallest.

@coveralls
Copy link

coveralls commented Oct 6, 2022

Pull Request Test Coverage Report for Build 3207601177

  • 167 of 190 (87.89%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.1%) to 85.765%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/ast/helpers/stmt_create_table.rs 146 157 92.99%
src/parser.rs 21 33 63.64%
Totals Coverage Status
Change from base Build 3207559008: 0.1%
Covered Lines: 10453
Relevant Lines: 12188

💛 - Coveralls

@alamb
Copy link
Contributor

alamb commented Oct 7, 2022

I think this makes a lot of sense to me 👍

I think it needs some docstrings (ideally with an example) but otherwise 🚀

@AugustoFKL
Copy link
Contributor Author

I think this makes a lot of sense to me 👍

I think it needs some docstrings (ideally with an example) but otherwise 🚀

Ok! Will be done in 10 :)

@AugustoFKL
Copy link
Contributor Author

@alamb done!

@alamb
Copy link
Contributor

alamb commented Oct 7, 2022

Looks like there is a minor issue with rustfmt/clippy

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.

LGTM -- thanks @AugustoFKL

Comment on lines 15 to 16
/// This structure is a facilitator to allow building and accessing a create table with more ease,
/// without needing to:
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
/// This structure is a facilitator to allow building and accessing a create table with more ease,
/// without needing to:
/// This structure helps building and accessing a `create table` with more ease,
/// without needing to:

/// builder.build().to_string(),
/// "CREATE TABLE IF NOT EXISTS table_name (c1 INT)"
/// )
///
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
///

assert_eq!(builder, CreateTableBuilder::try_from(stmt).unwrap());
}

#[test]
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

@alamb
Copy link
Contributor

alamb commented Oct 7, 2022

It just needs to get a clean CI and we can merge it.

@alamb alamb merged commit a3194dd into apache:main Oct 7, 2022
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