Skip to content

Commit

Permalink
Core: Reset to main as part of replace shouldn't remove main ref
Browse files Browse the repository at this point in the history
  • Loading branch information
amogh-jahagirdar committed Dec 19, 2024
1 parent 540d6a6 commit 621b7af
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion core/src/main/java/org/apache/iceberg/MetadataUpdate.java
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,11 @@ public String name() {

@Override
public void applyTo(TableMetadata.Builder metadataBuilder) {
metadataBuilder.removeRef(refName);
if (refName.equals(SnapshotRef.MAIN_BRANCH)) {
metadataBuilder.resetMainBranch();
} else {
metadataBuilder.removeRef(refName);
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion core/src/main/java/org/apache/iceberg/TableMetadata.java
Original file line number Diff line number Diff line change
Expand Up @@ -1297,7 +1297,7 @@ public Builder removeRef(String name) {
return this;
}

private Builder resetMainBranch() {
protected Builder resetMainBranch() {
this.currentSnapshotId = -1;
SnapshotRef ref = refs.remove(SnapshotRef.MAIN_BRANCH);
if (ref != null) {
Expand Down

0 comments on commit 621b7af

Please sign in to comment.