raunaqmorarka commented on code in PR #17754:
URL: https://github.com/apache/iceberg/pull/17754#discussion_r4734850854
##########
core/src/main/java/org/apache/iceberg/MergingSnapshotProducer.java:
##########
@@ -977,15 +987,58 @@ protected void validateAddedDVs(
filterManifestsByPartition(base, conflictDetectionFilter,
newDeleteManifests),
ManifestFile::hasAddedFiles);
+ List<DeleteFile> concurrentDVs =
Collections.synchronizedList(Lists.newArrayList());
+
+ // only DVs added by delete operations can be merged
+ Set<Long> mergeableSnapshotIds;
+ if (canMergeConcurrentDVs) {
+ mergeableSnapshotIds =
+ newSnapshotIds.stream()
+ .filter(id ->
DataOperations.DELETE.equals(base.snapshot(id).operation()))
+ .collect(Collectors.toSet());
+ } else {
+ mergeableSnapshotIds = ImmutableSet.of();
+ }
+
Tasks.foreach(matchingManifests)
.stopOnFailure()
.throwFailureWhenFinished()
.executeWith(workerPool())
- .run(manifest -> validateAddedDVs(manifest, conflictDetectionFilter,
newSnapshotIds));
+ .run(
+ manifest ->
+ validateAddedDVs(
+ manifest,
+ conflictDetectionFilter,
+ newSnapshotIds,
+ mergeableSnapshotIds,
+ concurrentDVs));
+
+ if (!concurrentDVs.isEmpty()) {
+ // rows deleted by a merged DV may have been copied into concurrently
added data files
+ try (CloseableIterator<ManifestEntry<DataFile>> addedDataFiles =
+ addedDataFiles(base, startingSnapshotId, conflictDetectionFilter,
null, parent)
+ .iterator()) {
+ DeleteFile concurrentDV = concurrentDVs.get(0);
+ ValidationException.check(
+ !addedDataFiles.hasNext(),
Review Comment:
> Could we add a test where the new data file is outside the filter, so the
merge still happens?
Added `concurrentDVMergedWhenAddedDataFilesOutsideConflictFilter`.
> Could it say the merge was skipped because new data files were added?
The message is now "Cannot merge concurrently added DV for <data file>: data
files were added concurrently, e.g. <added data file>".
--
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]