You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@datafusion.apache.org by "LucaCappelletti94 (via GitHub)" <gi...@apache.org> on 2025/04/10 10:16:55 UTC
[PR] Adding support for `INHERITS` in `CREATE TABLE` parsing [datafusion-sqlparser-rs]
LucaCappelletti94 opened a new pull request, #1806:
URL: https://github.com/apache/datafusion-sqlparser-rs/pull/1806
This pull request will add support for parsing the `INHERITS` keyword in the `CREATE TABLE` statements.
Solves issue #1804
--
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-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] Add support for `INHERITS` option in `CREATE TABLE` statement [datafusion-sqlparser-rs]
Posted by "iffyio (via GitHub)" <gi...@apache.org>.
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-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] Add support for `INHERITS` option in `CREATE TABLE` statement [datafusion-sqlparser-rs]
Posted by "LucaCappelletti94 (via GitHub)" <gi...@apache.org>.
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<CreateTableConfiguration, ParserError> {
+ 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-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] Adding support for `INHERITS` in `CREATE TABLE` parsing [datafusion-sqlparser-rs]
Posted by "iffyio (via GitHub)" <gi...@apache.org>.
iffyio commented on code in PR #1806:
URL: https://github.com/apache/datafusion-sqlparser-rs/pull/1806#discussion_r2038856032
##########
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:
in place of the `should_panic`, we can rewrite the test case [in this form](https://github.com/apache/datafusion-sqlparser-rs/blob/165164bfc2d19fc61b3caec3fec2265c9173766a/tests/sqlparser_postgres.rs#L307-L310)
It would let us include the test case in the existing test function `parse_create_table_with_inherits` to help with grouping related test cases
##########
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<CreateTableConfiguration, ParserError> {
+ let inherits = if dialect_of!(self is BigQueryDialect | PostgreSqlDialect | GenericDialect)
Review Comment:
the `dialect_of` macro we're transitioning away from for new code, but I think in this case there's probably no need to gate this on dialect (also not sure BQ supports this syntax so it might be misleading to explicitly name BQ here) so that we can remove the check entirely and always parse the `INHERIT` option if it shows up in the statement?
--
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-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] Add support for `INHERITS` option in `CREATE TABLE` statement [datafusion-sqlparser-rs]
Posted by "LucaCappelletti94 (via GitHub)" <gi...@apache.org>.
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-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org