Skip to content

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

Open
ggevay wants to merge 1 commit into
MaterializeInc:mainfrom
ggevay:fix-create-table-no-cols
Open

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

Conversation

@ggevay
Copy link
Copy Markdown
Contributor

@ggevay ggevay commented Jun 2, 2026

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

1 participant