From df7f77106eab4d1b0e9fcc00d49c9c7b6ac933f1 Mon Sep 17 00:00:00 2001
From: Linwei Zhang <lewiszlw520@gmail.com>
Date: Mon, 9 Oct 2023 21:01:04 +0800
Subject: [PATCH 1/4] Improve update error

---
 datafusion/core/src/physical_planner.rs  | 5 +++--
 datafusion/expr/src/logical_plan/dml.rs  | 2 +-
 datafusion/expr/src/logical_plan/plan.rs | 2 +-
 3 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/datafusion/core/src/physical_planner.rs b/datafusion/core/src/physical_planner.rs
index 35119f374fa37..ddeeb4dcc9ef3 100644
--- a/datafusion/core/src/physical_planner.rs
+++ b/datafusion/core/src/physical_planner.rs
@@ -1251,10 +1251,11 @@ impl DefaultPhysicalPlanner {
                         "Unsupported logical plan: Prepare"
                     )
                 }
-                LogicalPlan::Dml(_) => {
+                LogicalPlan::Dml(dml) => {
                     // DataFusion is a read-only query engine, but also a library, so consumers may implement this
+                    let op = dml.op;
                     not_impl_err!(
-                        "Unsupported logical plan: Dml"
+                        "Unsupported logical plan: Dml({op})"
                     )
                 }
                 LogicalPlan::Statement(statement) => {
diff --git a/datafusion/expr/src/logical_plan/dml.rs b/datafusion/expr/src/logical_plan/dml.rs
index 4cd56b89ac635..0b566b58d546c 100644
--- a/datafusion/expr/src/logical_plan/dml.rs
+++ b/datafusion/expr/src/logical_plan/dml.rs
@@ -105,7 +105,7 @@ impl DmlStatement {
     }
 }
 
-#[derive(Clone, PartialEq, Eq, Hash)]
+#[derive(Copy, Clone, PartialEq, Eq, Hash)]
 pub enum WriteOp {
     InsertOverwrite,
     InsertInto,
diff --git a/datafusion/expr/src/logical_plan/plan.rs b/datafusion/expr/src/logical_plan/plan.rs
index dfc83f9eec766..b865b6855724c 100644
--- a/datafusion/expr/src/logical_plan/plan.rs
+++ b/datafusion/expr/src/logical_plan/plan.rs
@@ -142,7 +142,7 @@ pub enum LogicalPlan {
     Prepare(Prepare),
     /// Data Manipulaton Language (DML): Insert / Update / Delete
     Dml(DmlStatement),
-    /// Data Definition Language (DDL): CREATE / DROP TABLES / VIEWS / SCHEMAs
+    /// Data Definition Language (DDL): CREATE / DROP TABLES / VIEWS / SCHEMAS
     Ddl(DdlStatement),
     /// `COPY TO` for writing plan results to files
     Copy(CopyTo),

From 971f711183409f1a7809a76c2681f453467b1160 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=BC=A0=E6=9E=97=E4=BC=9F?= <lewiszlw520@gmail.com>
Date: Thu, 12 Oct 2023 14:14:21 +0800
Subject: [PATCH 2/4] Update datafusion/expr/src/logical_plan/dml.rs

Co-authored-by: Alex Huang <huangweijun1001@gmail.com>
---
 datafusion/expr/src/logical_plan/dml.rs | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/datafusion/expr/src/logical_plan/dml.rs b/datafusion/expr/src/logical_plan/dml.rs
index 0b566b58d546c..4cd56b89ac635 100644
--- a/datafusion/expr/src/logical_plan/dml.rs
+++ b/datafusion/expr/src/logical_plan/dml.rs
@@ -105,7 +105,7 @@ impl DmlStatement {
     }
 }
 
-#[derive(Copy, Clone, PartialEq, Eq, Hash)]
+#[derive(Clone, PartialEq, Eq, Hash)]
 pub enum WriteOp {
     InsertOverwrite,
     InsertInto,

From f415dd5bd824f647c89108dcf6a37c3798a2a38f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=BC=A0=E6=9E=97=E4=BC=9F?= <lewiszlw520@gmail.com>
Date: Thu, 12 Oct 2023 14:14:26 +0800
Subject: [PATCH 3/4] Update datafusion/core/src/physical_planner.rs

Co-authored-by: Alex Huang <huangweijun1001@gmail.com>
---
 datafusion/core/src/physical_planner.rs | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/datafusion/core/src/physical_planner.rs b/datafusion/core/src/physical_planner.rs
index ddeeb4dcc9ef3..5ebea7241a49f 100644
--- a/datafusion/core/src/physical_planner.rs
+++ b/datafusion/core/src/physical_planner.rs
@@ -1255,7 +1255,7 @@ impl DefaultPhysicalPlanner {
                     // DataFusion is a read-only query engine, but also a library, so consumers may implement this
                     let op = dml.op;
                     not_impl_err!(
-                        "Unsupported logical plan: Dml({op})"
+                        "Unsupported logical plan: Dml({0})", dml.op
                     )
                 }
                 LogicalPlan::Statement(statement) => {

From acd7f0452227f99d1d99001fe383e740136ba7a5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=BC=A0=E6=9E=97=E4=BC=9F?= <lewiszlw520@gmail.com>
Date: Thu, 12 Oct 2023 14:14:32 +0800
Subject: [PATCH 4/4] Update datafusion/core/src/physical_planner.rs

Co-authored-by: Alex Huang <huangweijun1001@gmail.com>
---
 datafusion/core/src/physical_planner.rs | 1 -
 1 file changed, 1 deletion(-)

diff --git a/datafusion/core/src/physical_planner.rs b/datafusion/core/src/physical_planner.rs
index 5ebea7241a49f..c2ab2a18cd664 100644
--- a/datafusion/core/src/physical_planner.rs
+++ b/datafusion/core/src/physical_planner.rs
@@ -1253,7 +1253,6 @@ impl DefaultPhysicalPlanner {
                 }
                 LogicalPlan::Dml(dml) => {
                     // DataFusion is a read-only query engine, but also a library, so consumers may implement this
-                    let op = dml.op;
                     not_impl_err!(
                         "Unsupported logical plan: Dml({0})", dml.op
                     )
