[spark] Support deleted record metrics for V2 delete#8486
Open
kerwin-zk wants to merge 1 commit into
Open
Conversation
JingsongLi
reviewed
Jul 7, 2026
| // For DELETE, the number of deleted records is exactly the row count difference between | ||
| // the removed files and the rewritten files. For UPDATE and MERGE, the rewritten files | ||
| // mix copied rows with modified rows, so record metrics cannot be derived from file stats. | ||
| if (operationType.contains(Snapshot.Operation.DELETE)) { |
Contributor
There was a problem hiding this comment.
This condition misses the DELETE plan used by the added test: metrics("deletedRecords") is absent before the write runs. I ran mvn -pl paimon-spark/paimon-spark-ut -am -Pfast-build -DfailIfNoTests=false -DwildcardSuites=org.apache.paimon.spark.sql.PaimonMetricTest -Dtest=none test, and Paimon Metric: delete fails with NoSuchElementException: key not found: deletedRecords at PaimonMetricTest.scala:188. Since Spark builds the command metrics from supportedCustomMetrics, we need to register PaimonDeletedRecordsMetric for the row-level DELETE write path that actually reaches this test, or ensure operationType is populated before supportedCustomMetrics is queried.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Purpose
This PR adds a
number of deleted recordscommit metric for V2 copy-on-write DELETE. The V2 row-level operation path only applies to append tables without deletion vectors or data evolution, so the file-level row counts are exact and the number of deleted records is exactly:The value is computed at commit time from the commit messages (no extra IO) and posted through the existing driver metrics mechanism.
For UPDATE and MERGE, the rewritten files mix copied rows with modified rows, so record-level counts cannot be derived from file statistics and remain unreported.
Tests
Extended
PaimonMetricTest("Paimon Metric: delete") to assertdeletedRecordsfor both a partial-file delete and a whole-file delete.