Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Core: Reset to main as part of replace shouldn't remove main ref #11819

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
}
Comment on lines +341 to +345
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah at this point we may as well make TableMetadata.removeRef not clear the log if it's main, and just have the consistent behavior for resetting to main. I feel like that's the sane default for that API now but the only issue is if others depend on that behavior

}
}

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