This is an automated email from the ASF dual-hosted git repository.
yjshen pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow-datafusion.git
The following commit(s) were added to refs/heads/main by this push:
new ae4b52a739 Minor: add `WriteOp::name` and `DmlStatement::name` (#7329)
ae4b52a739 is described below
commit ae4b52a7397bd7f613ea3782a84cc27245d0d57d
Author: Andrew Lamb <[email protected]>
AuthorDate: Wed Aug 23 00:21:59 2023 -0400
Minor: add `WriteOp::name` and `DmlStatement::name` (#7329)
---
datafusion/expr/src/logical_plan/dml.rs | 28 +++++++++++++++++++++-------
1 file changed, 21 insertions(+), 7 deletions(-)
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())
+ }
+}