Skip to content

Create table builder structure - #659

Merged
alamb merged 2 commits into
apache:mainfrom
AugustoFKL:proposal-create-table-builder
Oct 7, 2022
Merged

alamb merged 2 commits into
apache:mainfrom
AugustoFKL:proposal-create-table-builder

Conversation

@AugustoFKL

Copy link
Copy Markdown
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

coveralls commented Oct 6, 2022 •

Copy link
Copy Markdown

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

alamb commented Oct 7, 2022

Copy link
Copy Markdown
Contributor

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
Copy Markdown
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
Copy Markdown
Contributor Author

@alamb done!

@alamb

alamb commented Oct 7, 2022

Copy link
Copy Markdown
Contributor

Looks like there is a minor issue with rustfmt/clippy

@alamb alamb left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM -- thanks @AugustoFKL

Comment thread src/ast/helpers/stmt_create_table.rs Outdated
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
Copy Markdown
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:

Comment thread src/ast/helpers/stmt_create_table.rs Outdated
/// builder.build().to_string(),
/// "CREATE TABLE IF NOT EXISTS table_name (c1 INT)"
/// )
///

Copy link
Copy Markdown
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
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

👍

@alamb

alamb commented Oct 7, 2022

Copy link
Copy Markdown
Contributor

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