snapshot
ManageSnapshots
¶
Bases: UpdateTableMetadata['ManageSnapshots']
Run snapshot management operations using APIs.
APIs include create branch, create tag, etc.
Use table.manage_snapshots().
We can also use context managers to make more changes. For example,
with table.manage_snapshots() as ms: ms.create_tag(snapshot_id1, "Tag_A").create_tag(snapshot_id2, "Tag_B")
Source code in pyiceberg/table/update/snapshot.py
724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 |
|
create_branch(snapshot_id, branch_name, max_ref_age_ms=None, max_snapshot_age_ms=None, min_snapshots_to_keep=None)
¶
Create a new branch pointing to the given snapshot id.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
snapshot_id
|
int
|
snapshot id of existing snapshot at which the branch is created. |
required |
branch_name
|
str
|
name of the new branch |
required |
max_ref_age_ms
|
Optional[int]
|
max ref age in milliseconds |
None
|
max_snapshot_age_ms
|
Optional[int]
|
max age of snapshots to keep in milliseconds |
None
|
min_snapshots_to_keep
|
Optional[int]
|
min number of snapshots to keep in milliseconds |
None
|
Returns: This for method chaining
Source code in pyiceberg/table/update/snapshot.py
create_tag(snapshot_id, tag_name, max_ref_age_ms=None)
¶
Create a new tag pointing to the given snapshot id.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
snapshot_id
|
int
|
snapshot id of the existing snapshot to tag |
required |
tag_name
|
str
|
name of the tag |
required |
max_ref_age_ms
|
Optional[int]
|
max ref age in milliseconds |
None
|
Returns:
Type | Description |
---|---|
ManageSnapshots
|
This for method chaining |