cloud-fan commented on code in PR #51091:
URL: https://github.com/apache/spark/pull/51091#discussion_r2161005913


##########
sql/core/src/test/scala/org/apache/spark/sql/connector/MergeIntoTableSuiteBase.scala:
##########
@@ -1771,6 +1776,176 @@ abstract class MergeIntoTableSuiteBase extends 
RowLevelOperationSuiteBase {
     }
   }
 
+  test("Merge metrics with matched clause") {
+    withTempView("source") {
+      createAndInitTable("pk INT NOT NULL, salary INT, dep STRING",
+        """{ "pk": 1, "salary": 100, "dep": "hr" }
+          |{ "pk": 2, "salary": 200, "dep": "software" }
+          |{ "pk": 3, "salary": 300, "dep": "hr" }
+          |""".stripMargin)
+
+      val sourceDF = Seq(1, 2, 10).toDF("pk")
+      sourceDF.createOrReplaceTempView("source")
+
+      val mergeExec = findMergeExec {
+        s"""MERGE INTO $tableNameAsString t
+           |USING source s
+           |ON t.pk = s.pk
+           |WHEN MATCHED AND salary < 200 THEN
+           | UPDATE SET salary = 1000
+           |""".stripMargin
+      }
+
+      // group based merge does a outer join on target to retain the original 
rows
+      // so pulls in more rows than delta based merge
+      assertMetric(mergeExec, "numTargetRowsCopied", 2, Some(0))

Review Comment:
   to make the test code more readable, I think the following is better
   ```
   assertMetric(mergeExec, "numTargetRowsCopied", if (deltaMerge) 0 else 2)
   ```



-- 
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