martin-g commented on code in PR #19633:
URL: https://github.com/apache/datafusion/pull/19633#discussion_r2662134791
##########
datafusion/sql/src/statement.rs:
##########
@@ -1362,6 +1362,53 @@ impl<S: ContextProvider> SqlToRel<'_, S> {
exec_err!("Function name not provided")
}
}
+ Statement::Truncate {
+ table_names,
+ partitions,
+ identity,
+ cascade,
+ on_cluster,
+ ..
+ } => {
+ if table_names.len() != 1 {
+ return not_impl_err!(
+ "TRUNCATE with multiple tables is not supported"
+ );
+ }
+
+ let target = &table_names[0];
+ if target.only {
+ return not_impl_err!("TRUNCATE with ONLY is not
supported");
+ }
+ if partitions.is_some() {
+ return not_impl_err!("TRUNCATE with PARTITION is not
supported");
+ }
+ if identity.is_some() {
+ return not_impl_err!(
+ "TRUNCATE with RESTART/CONTINUE IDENTITY is not
supported"
+ );
+ }
+ if cascade.is_some() {
+ return not_impl_err!(
+ "TRUNCATE with CASCADE/RESTRICT is not supported"
+ );
+ }
+ if on_cluster.is_some() {
+ return not_impl_err!("TRUNCATE with ON CLUSTER is not
supported");
+ }
+ let table =
self.object_name_to_table_reference(target.name.clone())?;
+ let source =
self.context_provider.get_table_source(table.clone())?;
+
+ Ok(LogicalPlan::Dml(DmlStatement::new(
+ table.clone(),
+ source,
+ WriteOp::Truncate,
+ Arc::new(LogicalPlan::EmptyRelation(EmptyRelation {
+ produce_one_row: false,
+ schema: DFSchemaRef::new(DFSchema::empty()),
Review Comment:
https://github.com/apache/datafusion/blob/47df535d2cd5aac5ad5a92bdc837f38e05ea0f0f/datafusion/expr/src/logical_plan/dml.rs#L147
says `the schema must match with table_schema`. Is this important here ?
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]