rdblue commented on code in PR #4071:
URL: https://github.com/apache/iceberg/pull/4071#discussion_r846831308
##########
core/src/main/java/org/apache/iceberg/TableMetadata.java:
##########
@@ -1305,15 +1329,23 @@ private void setBranchSnapshotInternal(Snapshot
snapshot, String branch) {
snapshotLog.add(new SnapshotLogEntry(lastUpdatedMillis,
replacementSnapshotId));
}
- SnapshotRef newRef;
+ SnapshotRef.Builder newRefBuilder;
if (ref != null) {
- newRef = SnapshotRef.builderFrom(ref, replacementSnapshotId).build();
+ newRefBuilder = SnapshotRef.builderFrom(ref, replacementSnapshotId);
} else {
- newRef = SnapshotRef.branchBuilder(replacementSnapshotId).build();
+ newRefBuilder = SnapshotRef.branchBuilder(replacementSnapshotId);
}
+ SnapshotRef newRef = newRefBuilder.minSnapshotsToKeep(minSnapshotsToKeep)
+ .maxSnapshotAgeMs(maxSnapshotAgeMs)
+ .maxRefAgeMs(maxRefAgeMs)
+ .build();
+
+ MetadataUpdate.SetSnapshotRef refUpdate =
+ new MetadataUpdate.SetSnapshotRef(branch, newRef.snapshotId(),
newRef.type(),
+ newRef.minSnapshotsToKeep(), newRef.maxSnapshotAgeMs(),
newRef.maxRefAgeMs());
Review Comment:
As I noted above, I think the right thing to do here is to build the ref and
then call `setRef`, rather than calling `refs.put` and `changs.add` here. Then
you don't need to pull out the ref retention settings. The builder will copy
them and `setRef` will create the `MetadataUpdate` class correctly.
--
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]