CaptainAni187 opened a new issue, #2108:
URL: https://github.com/apache/iceberg-go/issues/2108

   Follow-up to #2095, as discussed in its review. That PR made 
`table.MetadataBuilder.Build()` leave the metadata log unchanged. Three related 
spots still write builder state during `Build()`:
   
   **1. `view.MetadataBuilder.Build` appends to the version log on every 
call.** `view/metadata_builder.go:438-440` appends `versionHistoryEntry` to 
`b.versionLog` and never clears it, so building the same builder twice 
duplicates the entry:
   
   ```go
   b := newTestBuilder().SetLoc("location").AddSchema(newTestSchema(1)).
        AddVersion(newTestVersion(1, 
LastAddedID)).SetCurrentVersionID(LastAddedID)
   b.Build() // VersionLog() has 1 entry
   b.Build() // 2 entries
   b.Build() // 3 entries
   ```
   
   This is the same pattern #2091 had for tables. The fix would be the same: 
append to a copy.
   
   **2. `table.MetadataBuilder.updateSnapshotLog` writes back `b.snapshotLog`** 
(`table/metadata.go`, the `b.snapshotLog = newSnapsLog` assignment). As far as 
I can tell, running it again removes nothing more, so the result doesn't 
change, but it is still a side effect of `Build()`. It could compute the log on 
a copy and pass it into `commonMetadata`, like the metadata log now does.
   
   **3. `buildCommonMetadata` sets `b.lastUpdatedMS` on the first `Build()`**, 
so later builds and any builder cloned afterwards reuse that timestamp. 
Repeated builds returning the same timestamp seems reasonable, so I'd keep the 
behaviour and document it rather than change it, unless you'd prefer otherwise.
   
   I'm happy to take this.
   


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