Skip to content

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

Merged
alamb merged 2 commits into
apache:mainfrom
shuvamk:mysql-partition-selection-display
Sep 3, 2026
Merged

alamb merged 2 commits 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 <[email protected]>

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

# Conflicts:
#	tests/sqlparser_mysql.rs
@alamb
alamb enabled auto-merge September 3, 2026 14:38
@alamb
alamb added this pull request to the merge queue Sep 3, 2026
Merged via the queue into apache:main with commit 223a269 Sep 3, 2026
10 checks passed
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