Skip to content

Apache DataFusion SQL Query Engine

Minor: add `WriteOp::name` and `DmlStatement::name` (#7329)

Andrew Lambae4b52a7397b
diff --git a/datafusion/expr/src/logical_plan/dml.rs b/datafusion/expr/src/logical_plan/dml.rs
index db36f73d15..c5243d8305 100644
--- a/datafusion/expr/src/logical_plan/dml.rs
+++ b/datafusion/expr/src/logical_plan/dml.rs
@@ -55,6 +55,13 @@ pub struct DmlStatement {
pub input: Arc<LogicalPlan>,
}
+impl DmlStatement {
+ /// Return a descriptive name of this [`DmlStatement`]
+ pub fn name(&self) -> &str {
+ self.op.name()
+ }
+}
+
#[derive(Clone, PartialEq, Eq, Hash)]
pub enum WriteOp {
InsertOverwrite,
@@ -64,14 +71,21 @@ pub enum WriteOp {
Ctas,
}
-impl Display for WriteOp {
- fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+impl WriteOp {
+ /// Return a descriptive name of this [`WriteOp`]
+ pub fn name(&self) -> &str {
match self {
- WriteOp::InsertOverwrite => write!(f, "Insert Overwrite"),
- WriteOp::InsertInto => write!(f, "Insert Into"),
- WriteOp::Delete => write!(f, "Delete"),
- WriteOp::Update => write!(f, "Update"),
- WriteOp::Ctas => write!(f, "Ctas"),
+ WriteOp::InsertOverwrite => "Insert Overwrite",
+ WriteOp::InsertInto => "Insert Into",
+ WriteOp::Delete => "Delete",
+ WriteOp::Update => "Update",
+ WriteOp::Ctas => "Ctas",
}
}
}
+
+impl Display for WriteOp {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+ write!(f, "{}", self.name())
+ }
+}