zeroshade commented on code in PR #548:
URL: https://github.com/apache/iceberg-go/pull/548#discussion_r2307609862
##########
table/table.go:
##########
@@ -227,6 +228,45 @@ func (t Table) doCommit(ctx context.Context, updates
[]Update, reqs []Requiremen
return New(t.identifier, newMeta, newLoc, t.fsF, t.cat), nil
}
+// SnapshotAsOf finds the snapshot that was current as of or right before the
given timestamp.
+func (t Table) SnapshotAsOf(timestampMs int64, inclusive bool) *Snapshot {
+ entries := slices.Collect(t.metadata.SnapshotLogs())
+ for i := len(entries) - 1; i >= 0; i-- {
+ entry := entries[i]
+ if (inclusive && entry.TimestampMs <= timestampMs) ||
(!inclusive && entry.TimestampMs < timestampMs) {
+ return t.metadata.SnapshotByID(entry.SnapshotID)
+ }
+ }
+
+ return nil
+}
+
+// WithSnapshotAsOf creates a scan of the table as it existed at the given
timestamp.
+// Note: Cannot be combined with WithSnapshotID option - time travel
determines the snapshot.
+func (t Table) WithSnapshotAsOf(timestampMs int64, opts ...ScanOption) (*Scan,
error) {
Review Comment:
Would this make more sense as a `ScanOption` instead of a standalone
function?
--
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]