Re: [PR] Add support for `INHERITS` option in `CREATE TABLE` statement [datafusion-sqlparser-rs]
iffyio merged PR #1806: URL: https://github.com/apache/datafusion-sqlparser-rs/pull/1806 -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org - To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org For additional commands, e-mail: github-h...@datafusion.apache.org
Re: [PR] Add support for `INHERITS` option in `CREATE TABLE` statement [datafusion-sqlparser-rs]
LucaCappelletti94 commented on code in PR #1806: URL: https://github.com/apache/datafusion-sqlparser-rs/pull/1806#discussion_r2040655023 ## tests/sqlparser_postgres.rs: ## @@ -2733,6 +2733,39 @@ fn parse_create_brin() { } } +#[test] +fn parse_create_table_with_inherits() { +let single_inheritance_sql = +"CREATE TABLE child_table (child_column INT) INHERITS (public.parent_table)"; +match pg().verified_stmt(single_inheritance_sql) { +Statement::CreateTable(CreateTable { +inherits: Some(inherits), +.. +}) => { +assert_eq_vec(&["public", "parent_table"], &inherits[0].0); +} +_ => unreachable!(), +} + +let double_inheritance_sql = "CREATE TABLE child_table (child_column INT) INHERITS (public.parent_table, pg_catalog.pg_settings)"; +match pg().verified_stmt(double_inheritance_sql) { +Statement::CreateTable(CreateTable { +inherits: Some(inherits), +.. +}) => { +assert_eq_vec(&["public", "parent_table"], &inherits[0].0); +assert_eq_vec(&["pg_catalog", "pg_settings"], &inherits[1].0); +} +_ => unreachable!(), +} +} + +#[test] +#[should_panic] +fn parse_create_table_with_empty_inherits_fails() { +pg().verified_stmt("CREATE TABLE child_table (child_column INT) INHERITS ()"); Review Comment: Refactored test as described! -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org - To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org For additional commands, e-mail: github-h...@datafusion.apache.org
Re: [PR] Add support for `INHERITS` option in `CREATE TABLE` statement [datafusion-sqlparser-rs]
LucaCappelletti94 commented on code in PR #1806: URL: https://github.com/apache/datafusion-sqlparser-rs/pull/1806#discussion_r2040654851 ## src/parser/mod.rs: ## @@ -7070,13 +7071,22 @@ 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 { +let inherits = if dialect_of!(self is BigQueryDialect | PostgreSqlDialect | GenericDialect) Review Comment: The dialect thing must have been a copy paste from the line below and then my brain decided to drop that pointer of information - fixed as described! -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org - To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org For additional commands, e-mail: github-h...@datafusion.apache.org