From 6c4287d3ec638a235c8f768ad4149cf4ba45d132 Mon Sep 17 00:00:00 2001 From: Amogh Jahagirdar Date: Wed, 18 Dec 2024 18:30:52 -0700 Subject: [PATCH] Core: Reset to main as part of replace shouldn't remove main ref --- core/src/main/java/org/apache/iceberg/TableMetadata.java | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/core/src/main/java/org/apache/iceberg/TableMetadata.java b/core/src/main/java/org/apache/iceberg/TableMetadata.java index 9f6ffbcc8714..0cea4946d58f 100644 --- a/core/src/main/java/org/apache/iceberg/TableMetadata.java +++ b/core/src/main/java/org/apache/iceberg/TableMetadata.java @@ -1299,11 +1299,8 @@ public Builder removeRef(String name) { private Builder resetMainBranch() { this.currentSnapshotId = -1; - SnapshotRef ref = refs.remove(SnapshotRef.MAIN_BRANCH); - if (ref != null) { - changes.add(new MetadataUpdate.RemoveSnapshotRef(SnapshotRef.MAIN_BRANCH)); - } - + refs.remove(SnapshotRef.MAIN_BRANCH); + setBranchSnapshot(-1, SnapshotRef.MAIN_BRANCH); return this; }