-
Notifications
You must be signed in to change notification settings - Fork 675
Add PostgreSQL PARTITION OF syntax support #2127
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| // PostgreSQL PARTITION OF for child partition tables | |
| let partition_of = if dialect_of!(self is PostgreSqlDialect | GenericDialect) | |
| && self.parse_keywords(&[Keyword::PARTITION, Keyword::OF]) | |
| let partition_of = if self.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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| /// 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| /// 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| /// Parse PostgreSQL partition bound specification for PARTITION OF. | |
| /// | |
| /// Parses: `FOR VALUES partition_bound_spec | DEFAULT` | |
| /// Parse [ForValues] of a `PARTITION OF` clause. |
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