Skip to content

MySQL: print a space before PARTITION when displaying a table factor - #2423

Open
shuvamk wants to merge 1 commit into
apache:mainfrom
shuvamk:mysql-partition-selection-display
Open

MySQL: print a space before PARTITION when displaying a table factor#2423
shuvamk wants to merge 1 commit into
apache:mainfrom
shuvamk:mysql-partition-selection-display

Conversation

@shuvamk

@shuvamk shuvamk commented Aug 4, 2026

Copy link
Copy Markdown
Contributor
SELECT * FROM employees PARTITION (p0, p2)

round-trips to SELECT * FROM employeesPARTITION (p0, p2), which re-parses as a table function named employeesPARTITION taking arguments p0 and p2 — a different AST, not just different whitespace.

Display for TableFactor::Table writes PARTITION (...) with no leading space, unlike the sibling clauses in the same arm ( WITH ORDINALITY, {alias}, WITH (...)). The fix adds the space.

Test is parse_table_partition_selection in tests/sqlparser_mysql.rs, covering SELECT/UPDATE/DELETE, an alias, a join and the missing-parenthesis error path; it fails without the change. Table-level PARTITION selection had no test coverage before.

`SELECT * FROM employees PARTITION (p0, p2)` rendered back as
`SELECT * FROM employeesPARTITION (p0, p2)`, which re-parses as a table
function named `employeesPARTITION` with arguments `p0` and `p2` rather
than a partition selection on `employees`. The round trip therefore
changed the AST, not just the whitespace.

`Display for TableFactor::Table` emitted `PARTITION (...)` without a
leading space, unlike the sibling clauses in the same arm. Add it.

The regression test also pins the `UPDATE`, `DELETE`, alias, join and
missing-parenthesis cases, none of which had coverage.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.

1 participant