Skip to content

sql-parser: fix AstDisplay panic for CREATE TABLE FROM SOURCE with constraints only#36866

Merged
ggevay merged 1 commit into
MaterializeInc:mainfrom
ggevay:fix-create-table-no-cols
Jun 3, 2026
Merged

sql-parser: fix AstDisplay panic for CREATE TABLE FROM SOURCE with constraints only#36866
ggevay merged 1 commit into
MaterializeInc:mainfrom
ggevay:fix-create-table-no-cols

Conversation

@ggevay

@ggevay ggevay commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

CreateTableFromSourceStatement's AstDisplay entered the parenthesized block whenever columns were specified OR constraints were non-empty, but the inner match panicked on TableFromSourceColumns::NotSpecified. A statement like

    CREATE TABLE t (PRIMARY KEY (c)) FROM SOURCE foo (REFERENCE bar)

would crash as soon as the AST was formatted (e.g. via statement logging). Treat NotSpecified as a no-op and gate the ", " separator so constraints-only output stays valid SQL. Adds round-trip tests for the constraints-only case and for columns + constraints (both Defined and Named).

with constraints only

CreateTableFromSourceStatement's AstDisplay entered the
parenthesized block whenever columns were specified OR
constraints were non-empty, but the inner match panicked on
TableFromSourceColumns::NotSpecified. A statement like

    CREATE TABLE t (PRIMARY KEY (c)) FROM SOURCE foo (REFERENCE bar)

would crash as soon as the AST was formatted (e.g. via
statement logging). Treat NotSpecified as a no-op and gate the
", " separator so constraints-only output stays valid SQL.
Adds round-trip tests for the constraints-only case and for
columns + constraints (both Defined and Named).

Co-authored-by: Junie <junie@jetbrains.com>
@ggevay ggevay added the A-ADAPTER Topics related to the ADAPTER layer label Jun 2, 2026
@ggevay ggevay marked this pull request as ready for review June 2, 2026 12:45
@ggevay ggevay requested a review from a team as a code owner June 2, 2026 12:45
@ggevay ggevay requested a review from a team June 2, 2026 14:17

@martykulma martykulma 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.

thanks @ggevay - lgtm!

@ggevay ggevay merged commit 9f1a1d4 into MaterializeInc:main Jun 3, 2026
123 checks passed
antiguru pushed a commit that referenced this pull request Jun 3, 2026
…h constraints only (#36866)

CreateTableFromSourceStatement's AstDisplay entered the parenthesized
block whenever columns were specified OR constraints were non-empty, but
the inner match panicked on `TableFromSourceColumns::NotSpecified`. A
statement like
```
    CREATE TABLE t (PRIMARY KEY (c)) FROM SOURCE foo (REFERENCE bar)
```
would crash as soon as the AST was formatted (e.g. via statement
logging). Treat `NotSpecified` as a no-op and gate the ", " separator so
constraints-only output stays valid SQL. Adds round-trip tests for the
constraints-only case and for columns + constraints (both Defined and
Named).

Co-authored-by: Junie <junie@jetbrains.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-ADAPTER Topics related to the ADAPTER layer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants