badalprasadsingh commented on code in PR #1637:
URL: https://github.com/apache/iceberg-go/pull/1637#discussion_r3720102240


##########
table/metadata.go:
##########
@@ -390,6 +390,42 @@ func (b *MetadataBuilder) currentSnapshot() *Snapshot {
        return s
 }
 
+// currentSnapshotForRef returns the head snapshot for ref.
+// Empty or main refs return the current snapshot.
+// Unknown refs also fall back to the current snapshot.
+func (b *MetadataBuilder) currentSnapshotForRef(ref string) *Snapshot {
+       if ref == "" || ref == MainBranch {
+               return b.currentSnapshot()
+       }
+
+       r, ok := b.refs[ref]
+       if !ok {
+               return b.currentSnapshot()

Review Comment:
   Fixed.
   
   You are absolutely right. It was just as you described, moving with option 
one: `latestSnapshotForBranch` matches Java's 
`SnapshotUtil.latestSnapshot(freshBase, branch)`. Added 
`TestBranchCreateForksFromMainHeadAcrossRetry`, which reproduces the data loss 
on the pre-fix code.



-- 
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]

Reply via email to