You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@paimon.apache.org by "karan-canva (via GitHub)" <gi...@apache.org> on 2026/10/15 02:33:54 UTC
[PR] [iceberg] Fix incorrect snapshot summary totals [paimon]
karan-canva opened a new pull request, #10575:
URL: https://github.com/apache/paimon/pull/10575
### Purpose
Linked issue: close #10574
The snapshot summary that `IcebergCommitCallback` writes can undercount live files. `total-data-files`, `total-records` and `total-files-size` drift down, and can reach 0 while the manifests still have live files. `deleted-data-files`, `deleted-records` and `removed-files-size` can count more files than Iceberg removed. Engines that read these fields, such as Snowflake during refresh, can then decline to refresh the table.
There are two causes:
1. `collectFileChanges` filters ADD entries with `shouldAddFileToIceberg`, but not DELETE entries. Removed Paimon files that were never exported, such as low-level files of a primary-key table, were counted as deletions and subtracted from the running totals. Each compaction lowered the totals further.
2. `computeLiveFileCount` and `computeLiveRowCount` computed `added + existing - deleted` for each manifest. These counts are disjoint, so the live count is `added + existing`. The helpers undercounted whenever a manifest had DELETED entries. They were used when the previous snapshot had no totals, and for the delete-file totals.
The fix:
- The deleted counters come from the entries that `createWithDeleteManifestFileMetas` marks as DELETED, so they match what Iceberg removed. The DELETE entries are not filtered with `shouldAddFileToIceberg`. The first snapshot is built from raw-convertible splits and can export a level-0 file, and filtering would stop such a file from ever being marked DELETED.
- `total-data-files` and `total-records` are computed from the new data manifest list, the same way `total-delete-files` already is. They now always match the manifests, and tables that already have wrong totals are corrected on their next commit.
- File sizes are not in the manifest list, so `total-files-size` is still carried forward. When the previous `total-data-files` does not match the base manifests, the previous size total is not trusted and is recomputed from the manifests.
- `IcebergManifestFileMeta#liveFilesCount` (`added + existing`) is added next to `liveRowsCount`, and both helpers use them.
### Tests
- `IcebergCompatibilityTest#testSnapshotSummaryTotalsMatchManifests`, with and without deletion vectors: a primary-key table goes through three rounds of uncompacted writes followed by a full compaction with a delete. After every commit, `total-data-files`, `total-records`, `total-files-size`, `total-delete-files` and `total-position-deletes` must equal the live entries in the snapshot's manifests. `deleted-data-files`, `deleted-records` and `removed-files-size` must equal the entries the snapshot marked as DELETED. On master the first compaction writes `deleted-data-files=4` while Iceberg removed 1 file, and `total-data-files=0` while 1 file is live.
- `IcebergCompatibilityTest#testSnapshotSummaryTotalsRepairedWhenBaseTotalsAreUnusable`: the latest metadata has its totals either removed, as in metadata written before the counters existed, or set to 0, as in metadata written with the miscounted totals. The next append and compaction must write totals that match the manifests. On master both cases write `total-data-files=0`.
- `IcebergManifestFileMetaTest#testLiveCountsExcludeDeletedEntries`: a manifest with ADDED, EXISTING and DELETED entries reports live counts of `added + existing`.
- `mvn -pl paimon-core -Dtest='Iceberg*Test' test`: 192 tests pass. `mvn -Ppaimon-iceberg -pl paimon-iceberg test`: 65 tests pass, 2 skipped as on master. Checkstyle and spotless are clean.
### API and Format
No API change. The optional summary fields in Iceberg metadata now have correct values. No format change.
### Documentation
No.
Generated-by: Cursor (Claude Opus 5.5)
--
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: issues-unsubscribe@paimon.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [iceberg] Fix incorrect snapshot summary totals [paimon]
Posted by "karan-canva (via GitHub)" <gi...@apache.org>.
karan-canva commented on PR #10575:
URL: https://github.com/apache/paimon/pull/10575#issuecomment-6184801392
@JingsongLi @plusplusjiajia could you take a look when you have time? This fixes the Iceberg snapshot summary totals. They undercount live files and can reach 0, and Snowflake declines to refresh tables whose totals don't match their manifests. 2.0.0 and 2.1.0 are both affected, so we'd like this in 2.2.0 if possible. CI is green.
--
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: issues-unsubscribe@paimon.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [iceberg] Fix incorrect snapshot summary totals [paimon]
Posted by "karan-canva (via GitHub)" <gi...@apache.org>.
karan-canva commented on code in PR #10575:
URL: https://github.com/apache/paimon/pull/10575#discussion_r4289018801
##########
paimon-core/src/main/java/org/apache/paimon/iceberg/IcebergCommitCallback.java:
##########
@@ -1108,39 +1110,33 @@ private void createMetadataWithBase(
addedFiles.values().stream().mapToLong(p -> p.getRight().rowCount()).sum();
metrics.addedFilesSize =
addedFiles.values().stream().mapToLong(p -> p.getRight().fileSize()).sum();
- metrics.deletedDataFiles = removedFiles.size();
+ metrics.deletedDataFiles = deletedFiles.size();
metrics.deletedRecords =
- removedFiles.values().stream().mapToLong(p -> p.getRight().rowCount()).sum();
+ deletedFiles.stream().mapToLong(IcebergDataFileMeta::recordCount).sum();
metrics.deletedFilesSize =
- removedFiles.values().stream().mapToLong(p -> p.getRight().fileSize()).sum();
- metrics.changedPartitionCount = modifiedPartitionsSet.size();
-
- IcebergSnapshot baseSnapshot = baseMetadata.currentSnapshot();
+ deletedFiles.stream().mapToLong(IcebergDataFileMeta::fileSizeInBytes).sum();
+ Set<BinaryRow> changedPartitions = new HashSet<>();
Review Comment:
Thanks, confirmed. A commit that only changes deletion vectors reported `changed-partition-count=0`. Fixed in 8991d5bab.
When deletion vectors are exported, the count now also includes the partitions whose deletion vector index files were added or removed. It doesn't use the ADDED status in the new DELETES manifest, because that manifest is rebuilt with every entry ADDED whenever a deletion vector changes, and a retry passes every index file of the snapshot as ADD. Instead, the index files are compared with the live entries of the base DELETES manifests, so a partition counts only when its delete files actually changed.
Reading the base DELETES manifests showed that `IcebergDataFileMetaSerializer#fromRow` failed on delete file entries, which are written with null `null_value_counts`, `lower_bounds` and `upper_bounds`. `fromRow` now handles these null fields, and `IcebergDataFileMetaTest#testDeleteFileMetaRoundTrip` covers it.
`IcebergDVCompatibilityTest#testChangedPartitionCountWithDeletionVectorOnlyChange` is the v3 + bitmap64 regression case. It fully compacts two partitions, then deletes one existing key in each and lets minor compaction write deletion vectors, which must report 2 changed partitions. Then it does the same in one partition only, which must report 1, and checks the rows through the Iceberg reader. Without the fix the first of these commits reports 0. The helper in `IcebergCompatibilityTest` still skips DELETES manifests, since those tests don't export deletion vectors. The v3 case is covered in `paimon-iceberg`.
--
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: issues-unsubscribe@paimon.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [iceberg] Fix incorrect snapshot summary totals [paimon]
Posted by "JingsongLi (via GitHub)" <gi...@apache.org>.
JingsongLi merged PR #10575:
URL: https://github.com/apache/paimon/pull/10575
--
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: issues-unsubscribe@paimon.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [iceberg] Fix incorrect snapshot summary totals [paimon]
Posted by "JingsongLi (via GitHub)" <gi...@apache.org>.
JingsongLi commented on code in PR #10575:
URL: https://github.com/apache/paimon/pull/10575#discussion_r4282206536
##########
paimon-core/src/main/java/org/apache/paimon/iceberg/IcebergCommitCallback.java:
##########
@@ -1108,39 +1110,33 @@ private void createMetadataWithBase(
addedFiles.values().stream().mapToLong(p -> p.getRight().rowCount()).sum();
metrics.addedFilesSize =
addedFiles.values().stream().mapToLong(p -> p.getRight().fileSize()).sum();
- metrics.deletedDataFiles = removedFiles.size();
+ metrics.deletedDataFiles = deletedFiles.size();
metrics.deletedRecords =
- removedFiles.values().stream().mapToLong(p -> p.getRight().rowCount()).sum();
+ deletedFiles.stream().mapToLong(IcebergDataFileMeta::recordCount).sum();
metrics.deletedFilesSize =
- removedFiles.values().stream().mapToLong(p -> p.getRight().fileSize()).sum();
- metrics.changedPartitionCount = modifiedPartitionsSet.size();
-
- IcebergSnapshot baseSnapshot = baseMetadata.currentSnapshot();
+ deletedFiles.stream().mapToLong(IcebergDataFileMeta::fileSizeInBytes).sum();
+ Set<BinaryRow> changedPartitions = new HashSet<>();
Review Comment:
[P2] Include partitions changed only by deletion vectors
This now counts only data-file changes, so an Iceberg v3/DV64 primary-key table can publish a new delete file for a partition while reporting `changed-partition-count=0`. I reproduced this with the real Iceberg reader: write and fully compact 1,000 keys to L2, then delete one existing key and let lookup/minor compaction process the L0 tombstone. The original data file remains unchanged, Iceberg reads 999 rows, and the new DELETES manifest has one ADDED file (`total-position-deletes=1`, `total-delete-files=1`), but this summary reports zero changed partitions. The prior counter reports one for this same path. Please include partitions affected by added/removed delete files as well as data files, and add a v3+DV64 regression case. The current test helper skips DELETES manifests before collecting changed partitions, so it cannot detect this regression. [Iceberg's summary definition](https://iceberg.apache.org/spec/#snapshot-summary) includes partitions with files added or removed, wi
thout restricting them to data files.
--
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: issues-unsubscribe@paimon.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [iceberg] Fix incorrect snapshot summary totals [paimon]
Posted by "JingsongLi (via GitHub)" <gi...@apache.org>.
JingsongLi commented on PR #10575:
URL: https://github.com/apache/paimon/pull/10575#issuecomment-6217090286
+1
--
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: issues-unsubscribe@paimon.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org