amogh-jahagirdar commented on code in PR #4071:
URL: https://github.com/apache/iceberg/pull/4071#discussion_r846855901
##########
core/src/main/java/org/apache/iceberg/MetadataUpdate.java:
##########
@@ -227,31 +228,64 @@ public String name() {
@Override
public void applyTo(TableMetadata.Builder metadataBuilder) {
- // TODO: this should be generalized when tagging is supported
- metadataBuilder.removeBranch(name);
+ metadataBuilder.removeRef(name);
}
}
class SetSnapshotRef implements MetadataUpdate {
private final String name;
- private final long snapshotId;
-
- public SetSnapshotRef(String name, long snapshotId) {
+ private final Long snapshotId;
+ private final SnapshotRefType type;
+ private Integer minSnapshotsToKeep;
+ private Long maxSnapshotAgeMs;
+ private Long maxRefAgeMs;
+
+ public SetSnapshotRef(String name, Long snapshotId, SnapshotRefType type,
Integer minSnapshotsToKeep,
+ Long maxSnapshotAgeMs, Long maxRefAgeMs) {
this.name = name;
this.snapshotId = snapshotId;
+ this.type = type;
+ this.minSnapshotsToKeep = minSnapshotsToKeep;
+ this.maxSnapshotAgeMs = maxSnapshotAgeMs;
+ this.maxRefAgeMs = maxRefAgeMs;
}
public String name() {
return name;
}
+ public String type() {
+ return type.name().toLowerCase(Locale.ROOT);
+ }
+
public long snapshotId() {
return snapshotId;
}
+ public Integer minSnapshotsToKeep() {
+ return minSnapshotsToKeep;
+ }
+
+ public Long maxSnapshotAgeMs() {
+ return maxSnapshotAgeMs;
+ }
+
+ public Long maxRefAgeMs() {
+ return maxRefAgeMs;
+ }
+
@Override
public void applyTo(TableMetadata.Builder metadataBuilder) {
- metadataBuilder.setBranchSnapshot(snapshotId, name);
+ if (type == SnapshotRefType.BRANCH) {
Review Comment:
Got it. Yes originally I was leveraging setBranchSnapshot to get the logic
to update the snapshot history and (for addressing the failing tests) advancing
the current snapshot . However, as you pointed out this isn't correct. Updating
even in the setBranchSnapshot to use the retention properties on the ref is not
correct, because that is not the retention properties in the update, that is
the existing ref. So in our applyTo we would still be losing retention property
updates.
SetRef will have the logic for updating snapshot history. From this, I've
updated so that we only need setRef here and then setBranchSnapshotInternal
will use setRef.
--
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]