From c492510e6730cf0b2b34df59c5aa5c00553ff97a Mon Sep 17 00:00:00 2001 From: Andrew Lamb Date: Tue, 3 Nov 2026 17:00:28 -0500 Subject: [PATCH 1/3] chore: test sqlparser-rs 0.64.0 release branch before release Co-Authored-By: Claude Fable 5.1 --- Cargo.lock | 10 ++-- Cargo.toml | 2 +- .../examples/relation_planner/table_sample.rs | 6 ++- datafusion/sql/src/expr/mod.rs | 42 ++++++++++++----- datafusion/sql/src/planner.rs | 3 ++ datafusion/sql/src/relation/join.rs | 6 +++ datafusion/sql/src/statement.rs | 47 ++++++++++++++++--- datafusion/sql/src/unparser/ast.rs | 14 ++++-- datafusion/sql/src/unparser/expr.rs | 12 +++-- datafusion/sql/src/unparser/plan.rs | 1 + 10 files changed, 105 insertions(+), 38 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6fd56360c54f2..58a4f97b139ce 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6104,9 +6104,8 @@ dependencies = [ [[package]] name = "sqlparser" -version = "0.63.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3679862809bd1f92e563cf6fd820e28f39135303668001c10331d5027183e8b4" +version = "0.64.0" +source = "git+https://github.com/alamb/sqlparser-rs?rev=02097a8cc593e26976d8da587f3eaa74c9bde1e8#02097a8cc593e26976d8da587f3eaa74c9bde1e8" dependencies = [ "log", "recursive", @@ -6115,9 +6114,8 @@ dependencies = [ [[package]] name = "sqlparser_derive" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2905ae8e8148d8f7f5748ea95d1e949fa4fc1d7f5161547b758ad118b2e4b0aa" +version = "0.7.0" +source = "git+https://github.com/alamb/sqlparser-rs?rev=02097a8cc593e26976d8da587f3eaa74c9bde1e8#02097a8cc593e26976d8da587f3eaa74c9bde1e8" dependencies = [ "proc-macro2", "quote", diff --git a/Cargo.toml b/Cargo.toml index a96d3cbf37e58..877cf971e0a14 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -187,7 +187,7 @@ rstest = "0.28.0" serde = { version = "1", features = ["derive"] } serde_json = "1" sha2 = "^0.11.0" -sqlparser = { version = "0.63.0", default-features = false, features = ["std", "visitor"] } +sqlparser = { git = "https://github.com/alamb/sqlparser-rs", rev = "02097a8cc593e26976d8da587f3eaa74c9bde1e8", default-features = false, features = ["std", "visitor"] } stacker = "0.1.24" strum = "0.28.0" strum_macros = "0.28.0" diff --git a/datafusion-examples/examples/relation_planner/table_sample.rs b/datafusion-examples/examples/relation_planner/table_sample.rs index 13801a5fffc66..302f1be1ba6f4 100644 --- a/datafusion-examples/examples/relation_planner/table_sample.rs +++ b/datafusion-examples/examples/relation_planner/table_sample.rs @@ -320,7 +320,8 @@ impl RelationPlanner for TableSamplePlanner { with_ordinality, partitions, json_path, - index_hints, + index_directives, + inheritance, } = relation else { return Ok(RelationPlanning::Original(Box::new(relation))); @@ -371,7 +372,8 @@ impl RelationPlanner for TableSamplePlanner { with_ordinality, partitions, json_path, - index_hints, + index_directives, + inheritance, }; let input = context.plan(base_relation)?; diff --git a/datafusion/sql/src/expr/mod.rs b/datafusion/sql/src/expr/mod.rs index f5730573e1ed3..0dd277e109e18 100644 --- a/datafusion/sql/src/expr/mod.rs +++ b/datafusion/sql/src/expr/mod.rs @@ -12,8 +12,8 @@ use datafusion_expr::planner::{ use sqlparser::ast::{ AccessExpr, BinaryOperator, CastFormat, CastKind, CeilFloorKind, DataType as SQLDataType, DateTimeField, DictionaryField, Expr as SQLExpr, - ExprWithAlias as SQLExprWithAlias, JsonPath, JsonPathElem, MapEntry, Spanned, - StructField, Subscript, TrimWhereField, TypedString, Value, ValueWithSpan, + ExprWithAlias as SQLExprWithAlias, InTarget, JsonPath, JsonPathElem, MapEntry, + Spanned, StructField, Subscript, TrimWhereField, TypedString, Value, ValueWithSpan, }; use sqlparser::ast::{Query, Visit, Visitor}; @@ -580,11 +580,36 @@ impl SqlToRel<'_, S> { )?), ))), - SQLExpr::InList { + SQLExpr::In { expr, - list, + target, negated, - } => self.sql_in_list_to_expr(*expr, list, negated, schema, planner_context), + global, + } => { + if global { + return not_impl_err!("GLOBAL IN is not supported"); + } + match target { + InTarget::List(list) => self.sql_in_list_to_expr( + *expr, + list, + negated, + schema, + planner_context, + ), + InTarget::Subquery(subquery) => self.parse_in_subquery( + *expr, + *subquery, + negated, + schema, + planner_context, + ), + InTarget::Unnest(_) => not_impl_err!("IN UNNEST is not supported"), + InTarget::Table { .. } => { + not_impl_err!("IN is not supported") + } + } + } SQLExpr::Like { negated, @@ -728,13 +753,6 @@ impl SqlToRel<'_, S> { SQLExpr::Exists { subquery, negated } => { self.parse_exists_subquery(*subquery, negated, schema, planner_context) } - SQLExpr::InSubquery { - expr, - subquery, - negated, - } => { - self.parse_in_subquery(*expr, *subquery, negated, schema, planner_context) - } SQLExpr::Subquery(subquery) => { self.parse_scalar_subquery(*subquery, schema, planner_context) } diff --git a/datafusion/sql/src/planner.rs b/datafusion/sql/src/planner.rs index b51d1ab777595..e50332ace56dd 100644 --- a/datafusion/sql/src/planner.rs +++ b/datafusion/sql/src/planner.rs @@ -898,6 +898,9 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> { | SQLDataType::FixedString(_) | SQLDataType::Tuple(_) | SQLDataType::Nested(_) + | SQLDataType::Object(_) + | SQLDataType::Zerofill(_) + | SQLDataType::Collate(_, _) | SQLDataType::Union(_) | SQLDataType::Nullable(_) | SQLDataType::LowCardinality(_) diff --git a/datafusion/sql/src/relation/join.rs b/datafusion/sql/src/relation/join.rs index f7cf2b6e296b9..db679693fb012 100644 --- a/datafusion/sql/src/relation/join.rs +++ b/datafusion/sql/src/relation/join.rs @@ -159,6 +159,9 @@ impl SqlToRel<'_, S> { .asof_join_on(right, None, match_condition)? .build(), JoinConstraint::Natural => plan_err!("NATURAL ASOF JOIN is not supported"), + JoinConstraint::UsingAlias(_, _) => { + not_impl_err!("USING (...) AS alias is not supported") + } } } @@ -218,6 +221,9 @@ impl SqlToRel<'_, S> { .join_using(right, join_type, keys)? .build() } + JoinConstraint::UsingAlias(_, _) => { + not_impl_err!("USING (...) AS alias is not supported") + } JoinConstraint::Natural => { let left_cols: HashSet<&String> = left.schema().fields().iter().map(|f| f.name()).collect(); diff --git a/datafusion/sql/src/statement.rs b/datafusion/sql/src/statement.rs index e3701bc1a3814..625b654864888 100644 --- a/datafusion/sql/src/statement.rs +++ b/datafusion/sql/src/statement.rs @@ -199,6 +199,7 @@ fn calc_inline_constraints_from_columns(columns: &[ColumnDef]) -> Vec SqlToRel<'_, S> { constraints, if_not_exists, or_replace, - without_rowid, + sqlite_table_options, like, clone, comment, @@ -322,7 +323,6 @@ impl SqlToRel<'_, S> { partition_by, cluster_by, clustered_by, - strict, copy_grants, enable_schema_evolution, change_tracking, @@ -400,7 +400,10 @@ impl SqlToRel<'_, S> { if location.is_some() { return not_impl_err!("Location not supported"); } - if without_rowid { + if sqlite_table_options + .options + .contains(&ast::SqliteTableOption::WithoutRowid) + { return not_impl_err!("Without rowid not supported"); } if like.is_some() { @@ -433,7 +436,10 @@ impl SqlToRel<'_, S> { if clustered_by.is_some() { return not_impl_err!("Clustered by not supported"); } - if strict { + if sqlite_table_options + .options + .contains(&ast::SqliteTableOption::Strict) + { return not_impl_err!("Strict not supported"); } if copy_grants { @@ -1056,6 +1062,8 @@ impl SqlToRel<'_, S> { source, partitioned, after_columns, + by_name, + overriding, table, on, returning, @@ -1101,6 +1109,12 @@ impl SqlToRel<'_, S> { if !after_columns.is_empty() { plan_err!("After-columns clause not supported")?; } + if by_name { + plan_err!("INSERT BY NAME not supported")?; + } + if overriding.is_some() { + plan_err!("Insert-overriding clause not supported")?; + } if on.is_some() { plan_err!("Insert-on clause not supported")?; } @@ -1165,7 +1179,15 @@ impl SqlToRel<'_, S> { optimizer_hints, output, order_by, + on_cluster, + settings, }) => { + if on_cluster.is_some() { + plan_err!("UPDATE ON CLUSTER not supported")?; + } + if settings.is_some() { + plan_err!("Update with settings not supported")?; + } let from_clauses = from.map(|update_table_from_kind| match update_table_from_kind { UpdateTableFromKind::BeforeSet(from_clauses) => from_clauses, @@ -1217,10 +1239,18 @@ impl SqlToRel<'_, S> { delete_token: _, optimizer_hints, output, + on_cluster, + settings, }) => { if !tables.is_empty() { plan_err!("DELETE
not supported")?; } + if on_cluster.is_some() { + plan_err!("DELETE ON CLUSTER not supported")?; + } + if settings.is_some() { + plan_err!("Delete with settings not supported")?; + } if using.is_some() { plan_err!("Using clause not supported")?; @@ -1468,7 +1498,8 @@ impl SqlToRel<'_, S> { ast::CreateFunctionBody::AsBeforeOptions{body: expr, link_symbol: _link_symbol} => expr, ast::CreateFunctionBody::AsAfterOptions(expr) => expr, ast::CreateFunctionBody::Return(expr) => expr, - ast::CreateFunctionBody::AsBeginEnd(_) => { + ast::CreateFunctionBody::AsBeginEnd(_) + | ast::CreateFunctionBody::BeginAtomic(_) => { return not_impl_err!( "BEGIN/END enclosed function body syntax is not supported" )?; @@ -2466,7 +2497,8 @@ impl SqlToRel<'_, S> { partitions, json_path, sample, - index_hints, + index_directives, + inheritance, } => { if alias .as_ref() @@ -2483,7 +2515,8 @@ impl SqlToRel<'_, S> { || !partitions.is_empty() || json_path.is_some() || sample.is_some() - || !index_hints.is_empty() + || !index_directives.is_empty() + || inheritance.is_some() { return not_impl_err!( "MERGE target table modifiers are not supported" diff --git a/datafusion/sql/src/unparser/ast.rs b/datafusion/sql/src/unparser/ast.rs index 51c38b032a64e..851d4b07f504f 100644 --- a/datafusion/sql/src/unparser/ast.rs +++ b/datafusion/sql/src/unparser/ast.rs @@ -590,7 +590,7 @@ pub struct TableRelationBuilder { with_hints: Vec, version: Option, partitions: Vec, - index_hints: Vec, + index_directives: Vec, } impl TableRelationBuilder { @@ -618,8 +618,11 @@ impl TableRelationBuilder { self.partitions = value; self } - pub fn index_hints(&mut self, value: Vec) -> &mut Self { - self.index_hints = value; + pub fn index_directives( + &mut self, + value: Vec, + ) -> &mut Self { + self.index_directives = value; self } pub fn build(&self) -> Result { @@ -639,7 +642,8 @@ impl TableRelationBuilder { with_ordinality: false, json_path: None, sample: None, - index_hints: self.index_hints.clone(), + index_directives: self.index_directives.clone(), + inheritance: None, }) } fn create_empty() -> Self { @@ -650,7 +654,7 @@ impl TableRelationBuilder { with_hints: Default::default(), version: Default::default(), partitions: Default::default(), - index_hints: Default::default(), + index_directives: Default::default(), } } } diff --git a/datafusion/sql/src/unparser/expr.rs b/datafusion/sql/src/unparser/expr.rs index 053b1beb63e98..9f89903d118e4 100644 --- a/datafusion/sql/src/unparser/expr.rs +++ b/datafusion/sql/src/unparser/expr.rs @@ -158,10 +158,11 @@ impl Unparser<'_> { .iter() .map(|e| self.expr_to_sql_inner(e)) .collect::>>()?; - Ok(ast::Expr::InList { + Ok(ast::Expr::In { expr: Box::new(self.expr_to_sql_inner(expr)?), - list: list_expr, + target: ast::InTarget::List(list_expr), negated: *negated, + global: false, }) } Expr::ScalarFunction(ScalarFunction { func, args }) => { @@ -462,10 +463,11 @@ impl Unparser<'_> { "Subquery must be a Query, but found {sub_statement:?}" ); }; - Ok(ast::Expr::InSubquery { + Ok(ast::Expr::In { expr: inexpr, - subquery: sub_query, + target: ast::InTarget::Subquery(sub_query), negated: insubq.negated, + global: false, }) } Expr::SetComparison(set_cmp) => { @@ -3926,7 +3928,7 @@ mod tests { match tz { Some(tz) => ast::DataType::Custom( ObjectName::from(vec![Ident::new("TIMESTAMPTZ")]), - vec![tz.to_string()], + vec![ast::TypeModifier::Identifier(Ident::new(tz.to_string()))], ), None => ast::DataType::Timestamp(None, TimezoneInfo::None), } diff --git a/datafusion/sql/src/unparser/plan.rs b/datafusion/sql/src/unparser/plan.rs index 564de3a2816f6..ab2ef983992fe 100644 --- a/datafusion/sql/src/unparser/plan.rs +++ b/datafusion/sql/src/unparser/plan.rs @@ -2763,6 +2763,7 @@ impl Unparser<'_> { JoinType::Inner => match &constraint { ast::JoinConstraint::On(_) | ast::JoinConstraint::Using(_) + | ast::JoinConstraint::UsingAlias(_, _) | ast::JoinConstraint::Natural => ast::JoinOperator::Inner(constraint), ast::JoinConstraint::None => { // Inner joins with no conditions or filters are not valid SQL in most systems, From 2ea6d24a29082fadef2cc1a999661e4f2389e4a9 Mon Sep 17 00:00:00 2001 From: blaginin Date: Wed, 18 Nov 2026 19:39:10 +0000 Subject: [PATCH 2/3] fix: use sqlparser fork with ONLY regression fix --- Cargo.lock | 6 ++-- Cargo.toml | 2 +- datafusion/sql/src/planner.rs | 6 ++++ datafusion/sql/src/statement.rs | 5 +++ datafusion/sql/tests/sql_integration.rs | 33 ++++++++++++++++++++ datafusion/sqllogictest/test_files/alias.slt | 32 +++++++++++++++++++ 6 files changed, 79 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5dc832e839bc1..2939a33b1d042 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6105,8 +6105,7 @@ dependencies = [ [[package]] name = "sqlparser" version = "0.64.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92e0d273b4f8ddd14a35ed36862acbc9cc96cec578e36ee1881a9d42e0e0f2c8" +source = "git+https://github.com/blaginin/datafusion-sqlparser-rs?rev=01c9c23bcf0b44d86a7f65c624d0ed40a49b7eb1#01c9c23bcf0b44d86a7f65c624d0ed40a49b7eb1" dependencies = [ "log", "recursive", @@ -6116,8 +6115,7 @@ dependencies = [ [[package]] name = "sqlparser_derive" version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5fa4939c717eaef717f244768d35a5f93c62e1d440865097d2edef7d86ddb7e0" +source = "git+https://github.com/blaginin/datafusion-sqlparser-rs?rev=01c9c23bcf0b44d86a7f65c624d0ed40a49b7eb1#01c9c23bcf0b44d86a7f65c624d0ed40a49b7eb1" dependencies = [ "proc-macro2", "quote", diff --git a/Cargo.toml b/Cargo.toml index 848587bddc6a8..055bd781be2f5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -186,7 +186,7 @@ rstest = "0.28.0" serde = { version = "1", features = ["derive"] } serde_json = "1" sha2 = "^0.11.0" -sqlparser = { version = "0.64.0", default-features = false, features = ["std", "visitor"] } +sqlparser = { git = "https://github.com/blaginin/datafusion-sqlparser-rs", rev = "01c9c23bcf0b44d86a7f65c624d0ed40a49b7eb1", default-features = false, features = ["std", "visitor"] } stacker = "0.1.24" strum = "0.28.0" strum_macros = "0.28.0" diff --git a/datafusion/sql/src/planner.rs b/datafusion/sql/src/planner.rs index c6742abf0aa18..f75b5109be5fd 100644 --- a/datafusion/sql/src/planner.rs +++ b/datafusion/sql/src/planner.rs @@ -935,6 +935,12 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> { | SQLDataType::TsVector | SQLDataType::TsQuery | SQLDataType::GeometricType(_) + | SQLDataType::NationalCharacter(_) + | SQLDataType::NationalCharacterVarying(_) + | SQLDataType::NationalChar(_) + | SQLDataType::NationalCharVarying(_) + | SQLDataType::Nchar(_) + | SQLDataType::NcharVarying(_) | SQLDataType::DecimalUnsigned(_) // deprecated mysql type | SQLDataType::FloatUnsigned(_) // deprecated mysql type | SQLDataType::RealUnsigned // deprecated mysql type diff --git a/datafusion/sql/src/statement.rs b/datafusion/sql/src/statement.rs index 59f9eccec6a57..d1e3b1f8609ee 100644 --- a/datafusion/sql/src/statement.rs +++ b/datafusion/sql/src/statement.rs @@ -2054,6 +2054,11 @@ impl SqlToRel<'_, S> { TableConstraint::Check { .. } => { _plan_err!("Check constraints are not currently supported") } + TableConstraint::NotNull(_) => { + _plan_err!( + "Table-level NOT NULL constraints are not currently supported" + ) + } TableConstraint::Index { .. } => { _plan_err!("Indexes are not currently supported") } diff --git a/datafusion/sql/tests/sql_integration.rs b/datafusion/sql/tests/sql_integration.rs index 0e238a282df0e..58a4245d5e5d1 100644 --- a/datafusion/sql/tests/sql_integration.rs +++ b/datafusion/sql/tests/sql_integration.rs @@ -56,6 +56,39 @@ use sqlparser::parser::Parser; mod cases; mod common; +#[test] +fn unsupported_national_character_types() { + for sql_type in [ + "NATIONAL CHARACTER", + "NATIONAL CHARACTER VARYING", + "NATIONAL CHAR", + "NATIONAL CHAR VARYING", + "NCHAR", + "NCHAR VARYING", + ] { + let sql = format!("CREATE TABLE t (c {sql_type}(10))"); + let err = logical_plan(&sql).unwrap_err(); + assert_contains!( + err.to_string(), + format!("Unsupported SQL type {sql_type}(10)") + ); + } +} + +#[test] +fn unsupported_table_not_null_constraint() { + for sql in [ + "CREATE TABLE t (c INT, NOT NULL c)", + "CREATE TABLE t (c INT, CONSTRAINT nn NOT NULL c NO INHERIT)", + ] { + let err = logical_plan(sql).unwrap_err(); + assert_contains!( + err.to_string(), + "Table-level NOT NULL constraints are not currently supported" + ); + } +} + #[test] fn parse_decimals_1() { let sql = "SELECT 1"; diff --git a/datafusion/sqllogictest/test_files/alias.slt b/datafusion/sqllogictest/test_files/alias.slt index 9d1f8eded786a..a31d7e7bc1964 100644 --- a/datafusion/sqllogictest/test_files/alias.slt +++ b/datafusion/sqllogictest/test_files/alias.slt @@ -110,3 +110,35 @@ from (select "B.C" from t) as t_("x.y"); statement ok drop table t; + +statement ok +CREATE TABLE "only" AS SELECT 100 AS id; + +statement ok +CREATE TABLE t AS SELECT 200 AS id; + +query I +SELECT t.id FROM only t; +---- +100 + +query I +SELECT * FROM only; +---- +100 + +query I +SELECT t.id FROM only AS t; +---- +100 + +query I +SELECT * FROM public.only; +---- +100 + +statement ok +DROP TABLE "only"; + +statement ok +DROP TABLE t; From 2f62d5fba2a700af039f58283058c14e44e8e735 Mon Sep 17 00:00:00 2001 From: blaginin Date: Tue, 24 Nov 2026 10:02:17 -0500 Subject: [PATCH 3/3] chore: test upstream sqlparser main for the next release --- Cargo.lock | 4 ++-- Cargo.toml | 5 ++++- datafusion/sql/src/statement.rs | 18 ++++++++++++++++++ datafusion/sqllogictest/test_files/ddl.slt | 9 +++++++++ 4 files changed, 33 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2939a33b1d042..02baa7721b122 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6105,7 +6105,7 @@ dependencies = [ [[package]] name = "sqlparser" version = "0.64.0" -source = "git+https://github.com/blaginin/datafusion-sqlparser-rs?rev=01c9c23bcf0b44d86a7f65c624d0ed40a49b7eb1#01c9c23bcf0b44d86a7f65c624d0ed40a49b7eb1" +source = "git+https://github.com/apache/datafusion-sqlparser-rs?rev=ba850faff0d7bde0193e4c8635fdf5155a801d97#ba850faff0d7bde0193e4c8635fdf5155a801d97" dependencies = [ "log", "recursive", @@ -6115,7 +6115,7 @@ dependencies = [ [[package]] name = "sqlparser_derive" version = "0.7.0" -source = "git+https://github.com/blaginin/datafusion-sqlparser-rs?rev=01c9c23bcf0b44d86a7f65c624d0ed40a49b7eb1#01c9c23bcf0b44d86a7f65c624d0ed40a49b7eb1" +source = "git+https://github.com/apache/datafusion-sqlparser-rs?rev=ba850faff0d7bde0193e4c8635fdf5155a801d97#ba850faff0d7bde0193e4c8635fdf5155a801d97" dependencies = [ "proc-macro2", "quote", diff --git a/Cargo.toml b/Cargo.toml index 055bd781be2f5..8798c51d37830 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -186,7 +186,10 @@ rstest = "0.28.0" serde = { version = "1", features = ["derive"] } serde_json = "1" sha2 = "^0.11.0" -sqlparser = { git = "https://github.com/blaginin/datafusion-sqlparser-rs", rev = "01c9c23bcf0b44d86a7f65c624d0ed40a49b7eb1", default-features = false, features = ["std", "visitor"] } +sqlparser = { version = "0.64.0", git = "https://github.com/apache/datafusion-sqlparser-rs", rev = "ba850faff0d7bde0193e4c8635fdf5155a801d97", default-features = false, features = [ + "std", + "visitor", +] } stacker = "0.1.24" strum = "0.28.0" strum_macros = "0.28.0" diff --git a/datafusion/sql/src/statement.rs b/datafusion/sql/src/statement.rs index d1e3b1f8609ee..985aec7b33482 100644 --- a/datafusion/sql/src/statement.rs +++ b/datafusion/sql/src/statement.rs @@ -108,6 +108,7 @@ fn calc_inline_constraints_from_columns(columns: &[ColumnDef]) -> Vec constraints.push(TableConstraint::Unique(UniqueConstraint { name: name.clone(), index_name: None, @@ -128,6 +129,7 @@ fn calc_inline_constraints_from_columns(columns: &[ColumnDef]) -> Vec Vec { constraints.push(TableConstraint::PrimaryKey(PrimaryKeyConstraint { name: name.clone(), @@ -156,6 +159,7 @@ fn calc_inline_constraints_from_columns(columns: &[ColumnDef]) -> Vec Vec constraints.push(TableConstraint::Check(CheckConstraint { name: name.clone(), expr: expr.clone(), no_inherit: false, enforced: None, + on_conflict: *on_conflict, })), ast::ColumnOption::Default(_) | ast::ColumnOption::Null @@ -350,6 +356,7 @@ impl SqlToRel<'_, S> { require_user, partition_of, for_values, + of_type, snapshot, with_storage_lifecycle_policy, diststyle, @@ -520,6 +527,9 @@ impl SqlToRel<'_, S> { if for_values.is_some() { return not_impl_err!("PARTITION OF .. FOR VALUES .. not supported"); } + if of_type.is_some() { + return not_impl_err!("Typed tables not supported"); + } if snapshot { return not_impl_err!("Snapshot tables not supported"); } @@ -2015,7 +2025,11 @@ impl SqlToRel<'_, S> { index_options: _, characteristics: _, nulls_distinct: _, + on_conflict, }) => { + if on_conflict.is_some() { + return _plan_err!("ON CONFLICT on constraints is not supported"); + } let constraint_name = match &name { Some(name) => &format!("unique constraint with name '{name}'"), None => "unique constraint", @@ -2036,7 +2050,11 @@ impl SqlToRel<'_, S> { include: _, index_options: _, characteristics: _, + on_conflict, }) => { + if on_conflict.is_some() { + return _plan_err!("ON CONFLICT on constraints is not supported"); + } // Get primary key indices in the schema let indices = self.get_constraint_column_indices( df_schema, diff --git a/datafusion/sqllogictest/test_files/ddl.slt b/datafusion/sqllogictest/test_files/ddl.slt index 083223644e2c5..f093dd0ccf85f 100644 --- a/datafusion/sqllogictest/test_files/ddl.slt +++ b/datafusion/sqllogictest/test_files/ddl.slt @@ -849,6 +849,15 @@ CREATE TABLE foo AS SELECT 1 WITH NO DATA; statement error DataFusion error: Error during planning: Exclude constraints are not currently supported CREATE TABLE foo (x int, EXCLUDE USING gist (x WITH =)); +statement error DataFusion error: This feature is not implemented: Typed tables not supported +CREATE TABLE foo OF public.row_type; + +statement error DataFusion error: Error during planning: ON CONFLICT on constraints is not supported +CREATE TABLE foo (x int, UNIQUE (x) ON CONFLICT IGNORE); + +statement error DataFusion error: Error during planning: ON CONFLICT on constraints is not supported +CREATE TABLE foo (x int, PRIMARY KEY (x) ON CONFLICT REPLACE); + query error DataFusion error: Schema error: No field named a\. EXPLAIN CREATE TABLE t(a int) AS VALUES (a + a);