amogh-jahagirdar commented on code in PR #15006:
URL: https://github.com/apache/iceberg/pull/15006#discussion_r2687267049
##########
core/src/main/java/org/apache/iceberg/MergingSnapshotProducer.java:
##########
@@ -1060,19 +1096,113 @@ private List<ManifestFile> newDeleteFilesAsManifests()
{
}
if (cachedNewDeleteManifests.isEmpty()) {
+ // Found duplicates, merge them and update newDeleteFilesBySpec to
remove duplicates and add
+ // the new merged one
+ if (!duplicateDVsForDataFile.isEmpty()) {
+ Map<String, DeleteFile> mergedDVs = mergeDuplicateDVs();
+ mergedDVs.forEach(
+ (referencedFile, newDV) -> {
+ DeleteFileSet duplicateDVs =
duplicateDVsForDataFile.get(referencedFile);
+ DeleteFileSet allDeleteFilesForSpec =
newDeleteFilesBySpec.get(newDV.specId());
+ LOG.warn(
+ "Merged {} duplicate deletion vectors for data file {} in
table {}. The merged DVs are orphaned, and writers should merge DVs per file
before committing",
+ duplicateDVs.size(),
+ referencedFile,
+ tableName);
+ allDeleteFilesForSpec.removeAll(duplicateDVs);
+ allDeleteFilesForSpec.add(newDV);
+ });
+ }
+
newDeleteFilesBySpec.forEach(
(specId, deleteFiles) -> {
PartitionSpec spec = ops().current().spec(specId);
+ deleteFiles.forEach(file -> addedFilesSummary.addedFile(spec,
file));
List<ManifestFile> newDeleteManifests =
writeDeleteManifests(deleteFiles, spec);
cachedNewDeleteManifests.addAll(newDeleteManifests);
});
this.hasNewDeleteFiles = false;
+ this.duplicateDVsForDataFile.clear();
Review Comment:
I believe we need to clear this state in case of retries
--
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]