amogh-jahagirdar commented on code in PR #9732:
URL: https://github.com/apache/iceberg/pull/9732#discussion_r1492738591


##########
core/src/main/java/org/apache/iceberg/TableMetadata.java:
##########
@@ -1246,7 +1246,6 @@ public Builder setRef(String name, SnapshotRef ref) {
     public Builder removeRef(String name) {
       if (SnapshotRef.MAIN_BRANCH.equals(name)) {
         this.currentSnapshotId = -1;
-        snapshotLog.clear();

Review Comment:
   While I get this fixes the behavior (and I tested locally , it seems we 
actually don't have any unit tests which validate the snapshot log after a 
replace metadata which I think we should add.)  I actually think this is not 
the right place to make the fix. 
   
   Here's my thinking:
   
   1.) The intention of the `removeRef` API is to essentially get rid of a 
reference. Now, we don't want to get rid of main because that's bad. I think 
this API should simply reset to -1 and remove history. Imagine I want to do a 
TableMetadata.builder().buildFrom(), and keep aspects like the 
partitioning/schema but I want to get rid of the history.
   
   2.) I think the fix should be done in the `buildReplacement` API. Instead of 
using `removeRef` we do a `setBranchSnapshot` to reset main to -1.
   
   let me know what you think! but overall I do think we should fix this 
behavior.



-- 
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: issues-unsubscr...@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org
For additional commands, e-mail: issues-h...@iceberg.apache.org

Reply via email to