Skip to content

Refactor: replace dialect_of! table partition check with Dialect trait method - #2526

Open
jerguslejko wants to merge 1 commit into
apache:mainfrom
jerguslejko:jergus/table-partitions-hook
Open

jerguslejko wants to merge 1 commit into
apache:mainfrom
jerguslejko:jergus/table-partitions-hook

Conversation

@jerguslejko

Copy link
Copy Markdown

Summary

Continues the work from #2171 and #2175 by replacing one more dialect_of! macro usage with a Dialect trait method, so user-defined dialects can opt into table-factor PARTITION parsing.

New trait method:

Method Description Dialects
supports_table_partitions PARTITION (p0, p1) on a table factor MySQL

Also implemented for GenericDialect (returning true), matching the dialects the previous dialect_of!(self is MySqlDialect | GenericDialect) check named. The default is false, so behaviour is unchanged for every existing dialect.

Motivation is the one described in #1430 and #1186: a custom dialect wrapping PostgreSqlDialect cannot reach this branch at all today, because dialect_of! is a TypeId check that only matches built-in dialects.

Test plan

  • All existing tests pass (1620 across 23 suites), including parse_table_partition_selection
  • New test in tests/sqlparser_custom_dialect.rs: a custom dialect opting in parses and round-trips SELECT * FROM employees PARTITION (p0, p1); one that does not opt in still rejects it
  • cargo clippy --all-targets --all-features -- -D warnings passes
  • cargo fmt --all -- --check passes

@jerguslejko
jerguslejko marked this pull request as ready for review September 18, 2026 08:20
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