databend_common_ast/ast/statements/
delete.rs1use std::fmt::Display;
16use std::fmt::Formatter;
17
18use derive_visitor::Drive;
19use derive_visitor::DriveMut;
20
21use crate::ast::Expr;
22use crate::ast::Hint;
23use crate::ast::TableReference;
24use crate::ast::With;
25
26#[derive(Debug, Clone, PartialEq, Drive, DriveMut)]
27pub struct DeleteStmt {
28 pub hints: Option<Hint>,
29 pub table: TableReference,
30 pub selection: Option<Expr>,
31 pub with: Option<With>,
33}
34
35impl Display for DeleteStmt {
36 fn fmt(&self, f: &mut Formatter) -> std::fmt::Result {
37 if let Some(cte) = &self.with {
38 write!(f, "WITH {} ", cte)?;
39 }
40 write!(f, "DELETE ")?;
41 if let Some(hints) = &self.hints {
42 write!(f, "{} ", hints)?;
43 }
44 write!(f, "FROM {}", self.table)?;
45 if let Some(conditions) = &self.selection {
46 write!(f, " WHERE {conditions}")?;
47 }
48 Ok(())
49 }
50}