Uh oh!
There was an error while loading. Please reload this page.
Add PostgreSQL PARTITION OF syntax support - #2127
Conversation
| // PostgreSQL PARTITION OF for child partition tables | ||
| let partition_of = if dialect_of!(self is PostgreSqlDialect | GenericDialect) | ||
| && self.parse_keywords(&[Keyword::PARTITION, Keyword::OF]) |
There was a problem hiding this comment.
| // PostgreSQL PARTITION OF for child partition tables | |
| let partition_of = ifdialect_of!(self is PostgreSqlDialect | GenericDialect) | |
| &&self.parse_keywords(&[Keyword::PARTITION,Keyword::OF]) | |
| let partition_of = ifself.parse_keywords(&[Keyword::PARTITION,Keyword::OF]) |
If possible we can skiip the dialect check and let the parser accept the PARTITION OF clause whenever it shows up in an input sql
| } | ||
| } | ||
| /// Parse a single partition bound value (MINVALUE, MAXVALUE, or expression). |
There was a problem hiding this comment.
| /// Parse a single partition bound value (MINVALUE, MAXVALUE, or expression). | |
| /// Parse a single [PartitionBoundValue]. |
| } | ||
| } | ||
| /// PostgreSQL partition bound specification for PARTITION OF. |
There was a problem hiding this comment.
| /// PostgreSQL partition bound specification for PARTITION OF. | |
| /// PostgreSQL partition bound specification for `PARTITION OF`. |
| /// Parse PostgreSQL partition bound specification for PARTITION OF. | ||
| /// | ||
| /// Parses: `FOR VALUES partition_bound_spec | DEFAULT` |
There was a problem hiding this comment.
| /// Parse PostgreSQL partition bound specification for PARTITION OF. | |
| /// | |
| /// Parses: `FOR VALUES partition_bound_spec | DEFAULT` | |
| /// Parse [ForValues] of a `PARTITION OF` clause. |
iffyio
commented
Dec 18, 2025
just in case @fmguerreiro please feel free to re-request review when ready |
| Box::new(PostgreSqlDialect {}), | ||
| Box::new(MySqlDialect {}), | ||
| Box::new(SQLiteDialect {}), | ||
| ]); |
There was a problem hiding this comment.
If the intent is to test all dialects I think the test could live in sqlparser_common.rs and shouldn't explicitly list the dialects rather it can use all_dialects() - if the syntax conflicts across dialects (thinking probably snowflake for example) then I would suggest we just skip this test and rely on the pg_and_generic coverage after all
d85fe74 to
690091cCompare- Add explicit check for FOR/DEFAULT after PARTITION OF with clear error message - Document intentional removal of dialect check for multi-dialect tool support - Add negative test cases for malformed PARTITION OF syntax
690091c to
904896dCompareUh oh!
There was an error while loading. Please reload this page.
Summary
This PR adds support for PostgreSQL's
CREATE TABLE ... PARTITION OFsyntax for creating child partition tables.Closes#2042
Changes
MODULUSandREMAINDERkeywords tosrc/keywords.rsForValuesenum andPartitionBoundValueenum tosrc/ast/ddl.rswith Display implementationspartition_ofandfor_valuesfields toCreateTablestructCreateTableBuilderinsrc/ast/helpers/stmt_create_table.rssrc/parser/mod.rsforPARTITION OF,FOR VALUES IN/FROM/TO/WITH, andDEFAULTsrc/ast/spans.rsto include new fieldssrc/ast/mod.rstests/sqlparser_postgres.rsSupported Syntax
Testing
cargo fmtpassesPostgreSqlDialectandGenericDialectas required