This is an automated email from the ASF dual-hosted git repository.
lzljs3620320 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/paimon.git
The following commit(s) were added to refs/heads/master by this push:
new fa73f493b [spark] fix when the delete condition does not match any
partitions (#3270)
fa73f493b is described below
commit fa73f493b8f7d25441866f2b4cdb6e576865f694
Author: Yann Byron <[email protected]>
AuthorDate: Sun Apr 28 18:18:35 2024 +0800
[spark] fix when the delete condition does not match any partitions (#3270)
---
.../apache/paimon/spark/commands/DeleteFromPaimonTableCommand.scala | 6 +++++-
.../scala/org/apache/paimon/spark/sql/DeleteFromTableTest.scala | 6 ++++++
2 files changed, 11 insertions(+), 1 deletion(-)
diff --git
a/paimon-spark/paimon-spark-common/src/main/scala/org/apache/paimon/spark/commands/DeleteFromPaimonTableCommand.scala
b/paimon-spark/paimon-spark-common/src/main/scala/org/apache/paimon/spark/commands/DeleteFromPaimonTableCommand.scala
index 30a2e6eae..6ce042e41 100644
---
a/paimon-spark/paimon-spark-common/src/main/scala/org/apache/paimon/spark/commands/DeleteFromPaimonTableCommand.scala
+++
b/paimon-spark/paimon-spark-common/src/main/scala/org/apache/paimon/spark/commands/DeleteFromPaimonTableCommand.scala
@@ -85,7 +85,11 @@ case class DeleteFromPaimonTableCommand(
val dropPartitions = matchedPartitions.map {
partition =>
rowDataPartitionComputer.generatePartValues(partition).asScala.asJava
}
- commit.dropPartitions(dropPartitions.asJava,
BatchWriteBuilder.COMMIT_IDENTIFIER)
+ if (dropPartitions.nonEmpty) {
+ commit.dropPartitions(dropPartitions.asJava,
BatchWriteBuilder.COMMIT_IDENTIFIER)
+ } else {
+ writer.commit(Seq.empty)
+ }
} else {
val commitMessages = if (withPrimaryKeys) {
performDeleteForPkTable(sparkSession)
diff --git
a/paimon-spark/paimon-spark-common/src/test/scala/org/apache/paimon/spark/sql/DeleteFromTableTest.scala
b/paimon-spark/paimon-spark-common/src/test/scala/org/apache/paimon/spark/sql/DeleteFromTableTest.scala
index 81f0d7753..7c76dd236 100644
---
a/paimon-spark/paimon-spark-common/src/test/scala/org/apache/paimon/spark/sql/DeleteFromTableTest.scala
+++
b/paimon-spark/paimon-spark-common/src/test/scala/org/apache/paimon/spark/sql/DeleteFromTableTest.scala
@@ -85,6 +85,12 @@ abstract class DeleteFromTableTestBase extends
PaimonSparkTestBase {
spark.sql("SELECT * FROM T ORDER BY id"),
Seq((2, "b", "2024")).toDF()
)
+
+ spark.sql("DELETE FROM T WHERE dt < '2023' OR dt > '2025'")
+ checkAnswer(
+ spark.sql("SELECT * FROM T ORDER BY id"),
+ Seq((2, "b", "2024")).toDF()
+ )
}
test("Paimon Delete: append-only table, condition contains IN/NOT IN
subquery") {