Add support for INHERITS option in CREATE TABLE statement (#1806)

This commit is contained in:
Luca Cappelletti 2025-04-12 18:03:43 +02:00 committed by GitHub
parent bbc80d7537
commit 896c088153
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 71 additions and 2 deletions

View file

@ -7050,6 +7050,7 @@ impl<'a> Parser<'a> {
.partition_by(create_table_config.partition_by)
.cluster_by(create_table_config.cluster_by)
.options(create_table_config.options)
.inherits(create_table_config.inherits)
.primary_key(primary_key)
.strict(strict)
.build())
@ -7070,13 +7071,20 @@ impl<'a> Parser<'a> {
}
}
/// Parse configuration like partitioning, clustering information during the table creation.
/// Parse configuration like inheritance, partitioning, clustering information during the table creation.
///
/// [BigQuery](https://cloud.google.com/bigquery/docs/reference/standard-sql/data-definition-language#syntax_2)
/// [PostgreSQL](https://www.postgresql.org/docs/current/ddl-partitioning.html)
/// [PostgreSQL Partitioning](https://www.postgresql.org/docs/current/ddl-partitioning.html)
/// [PostgreSQL Inheritance](https://www.postgresql.org/docs/current/ddl-inherit.html)
fn parse_optional_create_table_config(
&mut self,
) -> Result<CreateTableConfiguration, ParserError> {
let inherits = if self.parse_keyword(Keyword::INHERITS) {
Some(self.parse_parenthesized_qualified_column_list(IsOptional::Mandatory, false)?)
} else {
None
};
let partition_by = if dialect_of!(self is BigQueryDialect | PostgreSqlDialect | GenericDialect)
&& self.parse_keywords(&[Keyword::PARTITION, Keyword::BY])
{
@ -7105,6 +7113,7 @@ impl<'a> Parser<'a> {
partition_by,
cluster_by,
options,
inherits,
})
}