Skip to content
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

Implement SQL parsing for CREATE TABLE .. FROM SOURCE [ENG-TASK-17] #28125

Merged
merged 1 commit into from
Jul 16, 2024

Conversation

rjobanp
Copy link
Contributor

@rjobanp rjobanp commented Jul 9, 2024

Motivation

Initial scaffolding for the work described in #27907 in service of https://github.com/MaterializeInc/database-issues/issues/6051

This just implements parsing of the new statement and will return an error during planning if this statement is actually used. In a follow on PR I'll be working on the planning bits.

Tips for reviewer

Checklist

@rjobanp rjobanp requested a review from a team July 10, 2024 17:00
@rjobanp rjobanp marked this pull request as ready for review July 10, 2024 17:00
@rjobanp rjobanp requested a review from a team as a code owner July 10, 2024 17:00
@rjobanp rjobanp requested a review from maddyblue July 10, 2024 17:00
// and include full definitions
match &columns {
None => {
return self.expected(
Copy link
Contributor

Choose a reason for hiding this comment

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

Checks like this and the diverging parse paths suggest that we may instead need a CreateTableFromSource top level struct. Thoughts? Would that make parsing easier to think about and remove the need for this verification?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes and no. We'd still need many of these checks during parsing since columns are optional in the 'from source' mode, and the column references can just be names rather than both names and types. But it could make downstream logic easier by having distinct CreateTableStatement and CreateTableFromSourceStatement structs, since I did have to make a couple of fields on CreateTableStatement optional to accommodate these semantics.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok. So that's same parsing but separate structs? That SGTM. Big fan of that if it prevents adding downstream validation that was previously not needed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep exactly! Thanks for the feedback, will refactor it when I'm back next week

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Alright I've replaced this commit with one that introduces a new top-level statement and it does make things dramatically simpler

Copy link
Contributor

@maddyblue maddyblue left a comment

Choose a reason for hiding this comment

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

Soo much cleaner!

src/sql-parser/src/ast/defs/statement.rs Outdated Show resolved Hide resolved
@rjobanp rjobanp merged commit 9c5a747 into MaterializeInc:main Jul 16, 2024
77 checks passed
@rjobanp rjobanp deleted the create-table-from-source branch July 16, 2024 13:36
@rjobanp rjobanp self-assigned this Jul 23, 2024
@bosconi bosconi changed the title Implement SQL parsing for CREATE TABLE .. FROM SOURCE Implement SQL parsing for CREATE TABLE .. FROM SOURCE [ENG-TASK-17] Jul 24, 2024
Copy link

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.

2 participants