kosiew commented on code in PR #26038:
URL: https://github.com/apache/datafusion/pull/26038#discussion_r4346354556


##########
datafusion/expr/src/logical_plan/dml.rs:
##########
@@ -560,6 +594,38 @@ pub enum MergeIntoAction {
     Delete,
 }
 
+impl Display for MergeIntoAction {
+    fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
+        match self {
+            Self::Update(assignments) => {
+                write!(f, "UPDATE SET ")?;
+                for (i, (column, value)) in assignments.iter().enumerate() {
+                    if i > 0 {
+                        write!(f, ", ")?;
+                    }
+                    write!(f, "{column} = {value}")?;

Review Comment:
   Could we use `datafusion_common::utils::quote_identifier` for UPDATE 
assignment targets and INSERT column names when quoting is needed? Currently 
`First Name` loses its identifier boundaries, and a name like `a, b` would look 
like two columns. Please adjust the existing test and include a comma or 
embedded-quote identifier. This is a readability improvement, not an execution 
issue.



##########
datafusion/sql/tests/sql_integration.rs:
##########
@@ -3979,6 +3979,20 @@ fn 
plan_merge_into_preserves_target_qualifier_and_quoted_columns() {
     };
     assert_eq!(columns, &["id".to_string(), "Age".to_string()]);
     assert_eq!(values[0].to_string(), "s.j2_id");
+
+    let display = plan.display_indent().to_string();
+    assert_contains!(
+        &display,
+        "Dml: op=[MergeInto] table=[person_quoted_cols] on=[t.id = s.j2_id] 
clauses=[WHEN MATCHED THEN UPDATE SET First Name = s.j2_string, WHEN NOT 
MATCHED THEN INSERT (id, Age) VALUES (s.j2_id, Int64(42))]"
+    );
+
+    let json = plan.display_pg_json().to_string();

Review Comment:
   Could we parse the JSON and assert the root `Clauses` array contains both 
expected strings in SQL order, along with `On`, `Operation`, and `Table Name`? 
The substring checks miss the array shape, second clause, and ordering. It 
would also help to test non-MERGE DML for the changed `Node Type` and absence 
of MERGE-only keys, and confirm that the broader node-type change is 
intentional.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to