rdblue commented on code in PR #19129:
URL: https://github.com/apache/iceberg/pull/19129#discussion_r4807574147
##########
core/src/main/java/org/apache/iceberg/MergingSnapshotProducer.java:
##########
@@ -1138,74 +1050,62 @@ protected NewSnapshotMetadata writeRootManifest(
}
@Override
- public List<ManifestFile> apply(TableMetadata base, Snapshot snapshot) {
- validateDeleteFilesForVersion(base.formatVersion());
- // filter any existing manifests
- List<ManifestFile> filtered =
- filterManager.filterManifests(
- SnapshotUtil.schemaFor(base, targetBranch()),
- snapshot != null ? snapshot.dataManifests(ops().io()) : null);
- long minDataSequenceNumber =
- filtered.stream()
- .map(ManifestFile::minSequenceNumber)
- .filter(
- seq ->
- seq
- != ManifestWriter
- .UNASSIGNED_SEQ) // filter out unassigned in
rewritten manifests
- .reduce(base.lastSequenceNumber(), Math::min);
- deleteFilterManager.dropDeleteFilesOlderThan(minDataSequenceNumber);
-
- // retrieve the data files to be deleted from the DataFileFilterManager
and pass it to the
- // DeleteFileFilterManager so that it can potentially remove orphaned DVs
- Set<DataFile> filesToBeDeleted = filterManager.filesToBeDeleted();
- deleteFilterManager.removeDanglingDeletesFor(filesToBeDeleted);
-
- List<ManifestFile> filteredDeletes =
- deleteFilterManager.filterManifests(
- SnapshotUtil.schemaFor(base, targetBranch()),
- snapshot != null ? snapshot.deleteManifests(ops().io()) : null);
-
- // only keep manifests that have live data files or that were written by
this commit
- Predicate<ManifestFile> shouldKeep =
- manifest ->
- manifest.hasAddedFiles()
- || manifest.hasExistingFiles()
- || manifest.snapshotId() == snapshotId();
- Iterable<ManifestFile> unmergedManifests =
- Iterables.filter(Iterables.concat(prepareNewDataManifests(),
filtered), shouldKeep);
- Iterable<ManifestFile> unmergedDeleteManifests =
- Iterables.filter(Iterables.concat(prepareDeleteManifests(),
filteredDeletes), shouldKeep);
-
- // update the snapshot summary
+ public List<ManifestFile> apply(TableMetadata base, Snapshot parent) {
+ ValidationException.check(
+ base.formatVersion() < 4,
+ "Cannot commit to table concurrently upgraded to v%s",
+ base.formatVersion());
+
+ List<ManifestFile> manifests = manifestListProducer.apply(base, parent,
targetBranch());
+
+ List<DataFile> deletedDataFiles = manifestListProducer.deletedDataFiles();
+ List<DeleteFile> deletedDeleteFiles =
manifestListProducer.deletedDeleteFiles();
+ if (failAnyDelete) {
+ ValidationException.check(
+ deletedDataFiles.isEmpty(),
+ "Operation would delete existing data: %s",
+ Lists.transform(deletedDataFiles, DataFile::location));
+ ValidationException.check(
+ deletedDeleteFiles.isEmpty(),
+ "Operation would delete existing delete files: %s",
+ Lists.transform(deletedDeleteFiles, DeleteFile::location));
+ }
+
+ if (failMissingDeletePaths) {
+ ValidationException.check(
+ manifestListProducer.missingDeletedDataFiles().isEmpty(),
+ "Missing required files to delete: %s",
+ Lists.transform(manifestListProducer.missingDeletedDataFiles(),
DataFile::location));
Review Comment:
I don't think that this is important and that the new assertions are more
correct. The important thing is not how the list is formatted, but that a
missing required file is identified. While it is less specific about the error
message, I don't think the test was "weakened" in a meaningful way.
--
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]