in table/snapshot_producers.go [636:689]
func (sp *snapshotProducer) commit() ([]Update, []Requirement, error) {
newManifests, err := sp.manifests()
if err != nil {
return nil, nil, err
}
nextSequence := sp.txn.meta.nextSequenceNumber()
summary, err := sp.summary(sp.snapshotProps)
if err != nil {
return nil, nil, err
}
fname := newManifestListFileName(sp.snapshotID, 0, sp.commitUuid)
locProvider, err := sp.txn.tbl.LocationProvider()
if err != nil {
return nil, nil, err
}
manifestListFilePath := locProvider.NewMetadataLocation(fname)
var parentSnapshot *int64
if sp.parentSnapshotID > 0 {
parentSnapshot = &sp.parentSnapshotID
}
out, err := sp.io.Create(manifestListFilePath)
if err != nil {
return nil, nil, err
}
defer out.Close()
err = iceberg.WriteManifestList(sp.txn.meta.formatVersion, out,
sp.snapshotID, parentSnapshot, &nextSequence, newManifests)
if err != nil {
return nil, nil, err
}
snapshot := Snapshot{
SnapshotID: sp.snapshotID,
ParentSnapshotID: parentSnapshot,
SequenceNumber: nextSequence,
ManifestList: manifestListFilePath,
Summary: &summary,
SchemaID: &sp.txn.meta.currentSchemaID,
TimestampMs: time.Now().UnixMilli(),
}
return []Update{
NewAddSnapshotUpdate(&snapshot),
NewSetSnapshotRefUpdate("main", sp.snapshotID, BranchRef, -1, -1, -1),
}, []Requirement{
AssertRefSnapshotID("main", sp.txn.meta.currentSnapshotID),
}, nil
}