You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@datafusion.apache.org by gi...@apache.org on 2026/02/27 10:34:20 UTC
(datafusion-sqlparser-rs) 01/01: Support parenthesized `CREATE TABLE ... (LIKE ... INCLUDING/EXCLUDING DEFAULTS)` in `PostgreSQL` (#2242)
This is an automated email from the ASF dual-hosted git repository.
github-bot pushed a commit to branch gh-readonly-queue/main/pr-2242-bd7f70e82048cab324dba6224fb3dd17757d8477
in repository https://gitbox.apache.org/repos/asf/datafusion-sqlparser-rs.git
commit 523d78ea2aceee54c4f999728edcb5603ff25a24
Author: Luca Cappelletti <ca...@gmail.com>
AuthorDate: Fri Feb 27 11:33:53 2026 +0100
Support parenthesized `CREATE TABLE ... (LIKE ... INCLUDING/EXCLUDING DEFAULTS)` in `PostgreSQL` (#2242)
---
src/dialect/postgresql.rs | 4 ++++
tests/sqlparser_postgres.rs | 39 +++++++++++++++++++++++++++++++++++++++
2 files changed, 43 insertions(+)
diff --git a/src/dialect/postgresql.rs b/src/dialect/postgresql.rs
index 0b7ed2a7..89b677c4 100644
--- a/src/dialect/postgresql.rs
+++ b/src/dialect/postgresql.rs
@@ -302,4 +302,8 @@ impl Dialect for PostgreSqlDialect {
fn supports_insert_table_alias(&self) -> bool {
true
}
+
+ fn supports_create_table_like_parenthesized(&self) -> bool {
+ true
+ }
}
diff --git a/tests/sqlparser_postgres.rs b/tests/sqlparser_postgres.rs
index 7c19f51e..f4b3a282 100644
--- a/tests/sqlparser_postgres.rs
+++ b/tests/sqlparser_postgres.rs
@@ -593,6 +593,45 @@ fn parse_create_table_constraints_only() {
};
}
+#[test]
+fn parse_create_table_like_with_defaults() {
+ let sql = "CREATE TABLE new (LIKE old INCLUDING DEFAULTS)";
+ match pg().verified_stmt(sql) {
+ Statement::CreateTable(stmt) => {
+ assert_eq!(
+ stmt.name,
+ ObjectName::from(vec![Ident::new("new".to_string())])
+ );
+ assert_eq!(
+ stmt.like,
+ Some(CreateTableLikeKind::Parenthesized(CreateTableLike {
+ name: ObjectName::from(vec![Ident::new("old".to_string())]),
+ defaults: Some(CreateTableLikeDefaults::Including),
+ }))
+ )
+ }
+ _ => unreachable!(),
+ }
+
+ let sql = "CREATE TABLE new (LIKE old EXCLUDING DEFAULTS)";
+ match pg().verified_stmt(sql) {
+ Statement::CreateTable(stmt) => {
+ assert_eq!(
+ stmt.name,
+ ObjectName::from(vec![Ident::new("new".to_string())])
+ );
+ assert_eq!(
+ stmt.like,
+ Some(CreateTableLikeKind::Parenthesized(CreateTableLike {
+ name: ObjectName::from(vec![Ident::new("old".to_string())]),
+ defaults: Some(CreateTableLikeDefaults::Excluding),
+ }))
+ )
+ }
+ _ => unreachable!(),
+ }
+}
+
#[test]
fn parse_alter_table_constraints_rename() {
match alter_table_op(
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datafusion.apache.org
For additional commands, e-mail: commits-help@datafusion.apache.org