Interface ManageSnapshots
-
- All Superinterfaces:
PendingUpdate<Snapshot>
- All Known Implementing Classes:
SnapshotManager
public interface ManageSnapshots extends PendingUpdate<Snapshot>
API for managing snapshots. Allows rolling table data back to a stated at an older tablesnapshot. Rollback:This API does not allow conflicting calls to
setCurrentSnapshot(long)androllbackToTime(long).When committing, these changes will be applied to the current table metadata. Commit conflicts will not be resolved and will result in a
CommitFailedException. Cherrypick:In an audit workflow, new data is written to an orphan
snapshotthat is not committed as the table's current state until it is audited. After auditing a change, it may need to be applied or cherry-picked on top of the latest snapshot instead of the one that was current when the audited changes were created. This class adds support for cherry-picking the changes from an orphan snapshot by applying them to the current snapshot. The output of the operation is a new snapshot with the changes from cherry-picked snapshot.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description ManageSnapshotscherrypick(long snapshotId)Apply supported changes in given snapshot and create a new snapshot which will be set as the current snapshot on commit.ManageSnapshotsrollbackTo(long snapshotId)Rollback table's state to a specificSnapshotidentified by id.ManageSnapshotsrollbackToTime(long timestampMillis)Roll this table's data back to the lastSnapshotbefore the given timestamp.ManageSnapshotssetCurrentSnapshot(long snapshotId)Roll this table's data back to a specificSnapshotidentified by id.-
Methods inherited from interface org.apache.iceberg.PendingUpdate
apply, commit, updateEvent
-
-
-
-
Method Detail
-
setCurrentSnapshot
ManageSnapshots setCurrentSnapshot(long snapshotId)
Roll this table's data back to a specificSnapshotidentified by id.- Parameters:
snapshotId- long id of the snapshot to roll back table data to- Returns:
- this for method chaining
- Throws:
java.lang.IllegalArgumentException- If the table has no snapshot with the given id
-
rollbackToTime
ManageSnapshots rollbackToTime(long timestampMillis)
Roll this table's data back to the lastSnapshotbefore the given timestamp.- Parameters:
timestampMillis- a long timestamp, as returned bySystem.currentTimeMillis()- Returns:
- this for method chaining
- Throws:
java.lang.IllegalArgumentException- If the table has no old snapshot before the given timestamp
-
rollbackTo
ManageSnapshots rollbackTo(long snapshotId)
Rollback table's state to a specificSnapshotidentified by id.- Parameters:
snapshotId- long id of snapshot id to roll back table to. Must be an ancestor of the current snapshot- Throws:
java.lang.IllegalArgumentException- If the table has no snapshot with the given idValidationException- If given snapshot id is not an ancestor of the current state
-
cherrypick
ManageSnapshots cherrypick(long snapshotId)
Apply supported changes in given snapshot and create a new snapshot which will be set as the current snapshot on commit.- Parameters:
snapshotId- a snapshotId whose changes to apply- Returns:
- this for method chaining
- Throws:
java.lang.IllegalArgumentException- If the table has no snapshot with the given idDuplicateWAPCommitException- In case of a WAP workflow and if the table has has a duplicate commit with same wapId
-
-