This is an automated email from the ASF dual-hosted git repository.
gurwls223 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/spark.git
The following commit(s) were added to refs/heads/master by this push:
new 24f600f7cc12 [SPARK-51725][SQL][TEST] Supplement tests for merge into
24f600f7cc12 is described below
commit 24f600f7cc1287d06f4f27d455e9dc2d9468d30c
Author: beliefer <[email protected]>
AuthorDate: Mon Apr 7 10:12:25 2025 +0900
[SPARK-51725][SQL][TEST] Supplement tests for merge into
### What changes were proposed in this pull request?
This PR proposes to supplement tests for merge into.
### Why are the changes needed?
Recently, I read the code about merge into and found we missing test cases
for a code path.
And I created a PR https://github.com/apache/spark/pull/50514 also proves
my point.
### Does this PR introduce _any_ user-facing change?
'No'.
Just about tests.
### How was this patch tested?
GA.
### Was this patch authored or co-authored using generative AI tooling?
'No'.
Closes #50522 from beliefer/SPARK-51725.
Authored-by: beliefer <[email protected]>
Signed-off-by: Hyukjin Kwon <[email protected]>
---
.../sql/connector/MergeIntoTableSuiteBase.scala | 29 ++++++++++++++++++++++
1 file changed, 29 insertions(+)
diff --git
a/sql/core/src/test/scala/org/apache/spark/sql/connector/MergeIntoTableSuiteBase.scala
b/sql/core/src/test/scala/org/apache/spark/sql/connector/MergeIntoTableSuiteBase.scala
index f74ad0a00247..86471ff8c456 100644
---
a/sql/core/src/test/scala/org/apache/spark/sql/connector/MergeIntoTableSuiteBase.scala
+++
b/sql/core/src/test/scala/org/apache/spark/sql/connector/MergeIntoTableSuiteBase.scala
@@ -169,6 +169,35 @@ abstract class MergeIntoTableSuiteBase extends
RowLevelOperationSuiteBase {
}
}
+ test("merge into empty table with multiple NOT MATCHED clause") {
+ withTempView("source") {
+ createTable("pk INT NOT NULL, salary INT, dep STRING")
+
+ val sourceRows = Seq(
+ (1, 100, "hr"),
+ (2, 200, "finance"),
+ (3, 300, "hr"))
+ sourceRows.toDF("pk", "salary", "dep").createOrReplaceTempView("source")
+
+ sql(
+ s"""MERGE INTO $tableNameAsString t
+ |USING source s
+ |ON t.pk = s.pk
+ |WHEN NOT MATCHED AND s.pk >= 2 THEN
+ | INSERT *
+ |WHEN NOT MATCHED THEN
+ | INSERT *
+ |""".stripMargin)
+
+ checkAnswer(
+ sql(s"SELECT * FROM $tableNameAsString"),
+ Seq(
+ Row(1, 100, "hr"), // insert
+ Row(2, 200, "finance"), // insert
+ Row(3, 300, "hr"))) // insert
+ }
+ }
+
test("merge into with conditional WHEN MATCHED clause (update)") {
withTempView("source") {
createAndInitTable("pk INT NOT NULL, salary INT, dep STRING",
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]