Interface ManageSnapshots
- All Superinterfaces:
PendingUpdate<Snapshot>
- All Known Implementing Classes:
SnapshotManager
snapshot
. Rollback:
This API does not allow conflicting calls to setCurrentSnapshot(long)
and rollbackToTime(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 snapshot
that 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
Modifier and TypeMethodDescriptioncherrypick
(long snapshotId) Apply supported changes in given snapshot and create a new snapshot which will be set as the current snapshot on commit.default ManageSnapshots
createBranch
(String name) Create a new branch.createBranch
(String name, long snapshotId) Create a new branch pointing to the given snapshot id.Create a new tag pointing to the given snapshot idfastForwardBranch
(String from, String to) Performs a fast-forward offrom
up to theto
snapshot iffrom
is an ancestor ofto
.removeBranch
(String name) Remove a branch by nameRemove the tag with the given name.renameBranch
(String name, String newName) Rename a branchreplaceBranch
(String name, long snapshotId) Replaces the branch with the given name to point to the specified snapshotreplaceBranch
(String from, String to) Replaces thefrom
branch to point to theto
snapshot.replaceTag
(String name, long snapshotId) Replaces the tag with the given name to point to the specified snapshot.rollbackTo
(long snapshotId) Rollback table's state to a specificSnapshot
identified by id.rollbackToTime
(long timestampMillis) Roll this table's data back to the lastSnapshot
before the given timestamp.setCurrentSnapshot
(long snapshotId) Roll this table's data back to a specificSnapshot
identified by id.setMaxRefAgeMs
(String name, long maxRefAgeMs) Updates the retention policy for a reference.setMaxSnapshotAgeMs
(String branchName, long maxSnapshotAgeMs) Updates the max snapshot age for a branch.setMinSnapshotsToKeep
(String branchName, int minSnapshotsToKeep) Updates the minimum number of snapshots to keep for a branch.Methods inherited from interface org.apache.iceberg.PendingUpdate
apply, commit, updateEvent
-
Method Details
-
setCurrentSnapshot
Roll this table's data back to a specificSnapshot
identified by id.- Parameters:
snapshotId
- long id of the snapshot to roll back table data to- Returns:
- this for method chaining
- Throws:
IllegalArgumentException
- If the table has no snapshot with the given id
-
rollbackToTime
Roll this table's data back to the lastSnapshot
before the given timestamp.- Parameters:
timestampMillis
- a long timestamp, as returned bySystem.currentTimeMillis()
- Returns:
- this for method chaining
- Throws:
IllegalArgumentException
- If the table has no old snapshot before the given timestamp
-
rollbackTo
Rollback table's state to a specificSnapshot
identified by id.- Parameters:
snapshotId
- long id of snapshot id to roll back table to. Must be an ancestor of the current snapshot- Throws:
IllegalArgumentException
- If the table has no snapshot with the given idValidationException
- If given snapshot id is not an ancestor of the current state
-
cherrypick
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:
IllegalArgumentException
- If the table has no snapshot with the given idDuplicateWAPCommitException
- In case of a WAP workflow and if the table has a duplicate commit with same wapId
-
createBranch
Create a new branch. The branch will point to current snapshot if the current snapshot is not NULL. Otherwise, the branch will point to a newly created empty snapshot.- Parameters:
name
- branch name- Returns:
- this for method chaining
- Throws:
IllegalArgumentException
- if a branch with the given name already exists
-
createBranch
Create a new branch pointing to the given snapshot id.- Parameters:
name
- branch namesnapshotId
- id of the snapshot which will be the head of the branch- Returns:
- this for method chaining
- Throws:
IllegalArgumentException
- if a branch with the given name already exists
-
createTag
Create a new tag pointing to the given snapshot id- Parameters:
name
- tag namesnapshotId
- snapshotId for the head of the new branch.- Returns:
- this for method chaining
- Throws:
IllegalArgumentException
- if a tag with the given name already exists
-
removeBranch
Remove a branch by name- Parameters:
name
- branch name- Returns:
- this for method chaining
- Throws:
IllegalArgumentException
- if the branch does not exist
-
renameBranch
Rename a branch- Parameters:
name
- name of branch to renamenewName
- the desired new name of the branch- Throws:
IllegalArgumentException
- if the branch to rename does not exist or if there is already a branch with the same name as the desired new name.
-
removeTag
Remove the tag with the given name.- Parameters:
name
- tag name- Returns:
- this for method chaining
- Throws:
IllegalArgumentException
- if the branch does not exist
-
replaceTag
Replaces the tag with the given name to point to the specified snapshot.- Parameters:
name
- Tag to replacesnapshotId
- new snapshot id for the given tag- Returns:
- this for method chaining
-
replaceBranch
Replaces the branch with the given name to point to the specified snapshot- Parameters:
name
- Branch to replacesnapshotId
- new snapshot id for the given branch- Returns:
- this for method chaining
-
replaceBranch
Replaces thefrom
branch to point to theto
snapshot. Theto
will remain unchanged, andfrom
branch will retain its retention properties. If thefrom
branch does not exist, it will be created with default retention properties.- Parameters:
from
- Branch to replaceto
- The branchfrom
should be replaced with- Returns:
- this for method chaining
-
fastForwardBranch
Performs a fast-forward offrom
up to theto
snapshot iffrom
is an ancestor ofto
. Theto
will remain unchanged, andfrom
will retain its retention properties. If thefrom
branch does not exist, it will be created with default retention properties.- Parameters:
from
- Branch to fast-forwardto
- Ref for thefrom
branch to be fast forwarded to- Returns:
- this for method chaining
- Throws:
IllegalArgumentException
- iffrom
is not an ancestor ofto
-
setMinSnapshotsToKeep
Updates the minimum number of snapshots to keep for a branch.- Parameters:
branchName
- branch nameminSnapshotsToKeep
- minimum number of snapshots to retain on the branch- Returns:
- this for method chaining
- Throws:
IllegalArgumentException
- if the branch does not exist
-
setMaxSnapshotAgeMs
Updates the max snapshot age for a branch.- Parameters:
branchName
- branch namemaxSnapshotAgeMs
- maximum snapshot age in milliseconds to retain on branch- Returns:
- this for method chaining
- Throws:
IllegalArgumentException
- if the branch does not exist
-
setMaxRefAgeMs
Updates the retention policy for a reference.- Parameters:
name
- branch namemaxRefAgeMs
- retention age in milliseconds of the tag reference itself- Returns:
- this for method chaining
- Throws:
IllegalArgumentException
- if the reference does not exist
-