@@ -25,6 +25,7 @@ use std::sync::Arc;
2525use super::dml::CopyTo;
2626use super::DdlStatement;
2727use crate::builder::{change_redundant_column, unnest_with_options};
28+ use crate::dml::Truncate;
2829use crate::expr::{Placeholder, Sort as SortExpr, WindowFunction};
2930use crate::expr_rewriter::{
3031 create_col_from_scalar_expr, normalize_cols, normalize_sorts, NamePreserver,
@@ -280,6 +281,8 @@ pub enum LogicalPlan {
280281 Unnest(Unnest),
281282 /// A variadic query (e.g. "Recursive CTEs")
282283 RecursiveQuery(RecursiveQuery),
284+ /// Truncate a table
285+ Truncate(Truncate),
283286}
284287
285288impl Default for LogicalPlan {
@@ -329,7 +332,8 @@ impl LogicalPlan {
329332 LogicalPlan::RecursiveQuery(RecursiveQuery { static_term, .. }) => {
330333 // we take the schema of the static term as the schema of the entire recursive query
331334 static_term.schema()
332- }
335+ },
336+ LogicalPlan::Truncate(Truncate{output_schema, ..}) => output_schema,
333337 }
334338 }
335339
@@ -481,7 +485,8 @@ impl LogicalPlan {
481485 | LogicalPlan::Statement { .. }
482486 | LogicalPlan::EmptyRelation { .. }
483487 | LogicalPlan::Values { .. }
484- | LogicalPlan::DescribeTable(_) => vec![],
488+ | LogicalPlan::DescribeTable(_)
489+ | LogicalPlan::Truncate(_) => vec![],
485490 }
486491 }
487492
@@ -598,7 +603,8 @@ impl LogicalPlan {
598603 | LogicalPlan::Copy(_)
599604 | LogicalPlan::Ddl(_)
600605 | LogicalPlan::DescribeTable(_)
601- | LogicalPlan::Unnest(_) => Ok(None),
606+ | LogicalPlan::Unnest(_)
607+ | LogicalPlan::Truncate(_) => Ok(None),
602608 }
603609 }
604610
@@ -767,7 +773,8 @@ impl LogicalPlan {
767773 }) => {
768774 // Update schema with unnested column type.
769775 unnest_with_options(Arc::unwrap_or_clone(input), exec_columns, options)
770- }
776+ },
777+ LogicalPlan::Truncate(_) => Ok(self),
771778 }
772779 }
773780
@@ -1117,7 +1124,8 @@ impl LogicalPlan {
11171124 LogicalPlan::EmptyRelation(_)
11181125 | LogicalPlan::Ddl(_)
11191126 | LogicalPlan::Statement(_)
1120- | LogicalPlan::DescribeTable(_) => {
1127+ | LogicalPlan::DescribeTable(_)
1128+ | LogicalPlan::Truncate(_) => {
11211129 // All of these plan types have no inputs / exprs so should not be called
11221130 self.assert_no_expressions(expr)?;
11231131 self.assert_no_inputs(inputs)?;
@@ -1367,7 +1375,8 @@ impl LogicalPlan {
13671375 | LogicalPlan::DescribeTable(_)
13681376 | LogicalPlan::Prepare(_)
13691377 | LogicalPlan::Statement(_)
1370- | LogicalPlan::Extension(_) => None,
1378+ | LogicalPlan::Extension(_)
1379+ | LogicalPlan::Truncate(_) => None,
13711380 }
13721381 }
13731382
@@ -1990,6 +1999,9 @@ impl LogicalPlan {
19901999 write!(f, "Unnest: lists[{}] structs[{}]",
19912000 expr_vec_fmt!(list_type_columns),
19922001 expr_vec_fmt!(struct_type_columns))
2002+ },
2003+ LogicalPlan::Truncate(_) => {
2004+ write!(f, "Truncate")
19932005 }
19942006 }
19952007 }
0 commit comments