snapshot
ExpireSnapshots
¶
Bases: UpdateTableMetadata['ExpireSnapshots']
Expire snapshots by ID.
Use table.expire_snapshots().
Source code in pyiceberg/table/update/snapshot.py
919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 |
|
by_id(snapshot_id)
¶
Expire a snapshot by its ID.
This will mark the snapshot for expiration.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
snapshot_id
|
int
|
The ID of the snapshot to expire. |
required |
Returns: This for method chaining.
Source code in pyiceberg/table/update/snapshot.py
by_ids(snapshot_ids)
¶
Expire multiple snapshots by their IDs.
This will mark the snapshots for expiration.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
snapshot_ids
|
List[int]
|
List of snapshot IDs to expire. |
required |
Returns: This for method chaining.
Source code in pyiceberg/table/update/snapshot.py
older_than(dt)
¶
Expire all unprotected snapshots with a timestamp older than a given value.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dt
|
datetime
|
Only snapshots with datetime < this value will be expired. |
required |
Returns:
Type | Description |
---|---|
'ExpireSnapshots'
|
This for method chaining. |
Source code in pyiceberg/table/update/snapshot.py
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
797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 |
|
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 for the branch |
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 |
Source code in pyiceberg/table/update/snapshot.py
remove_branch(branch_name)
¶
Remove a branch.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
branch_name
|
str
|
name of branch to remove |
required |
Returns: This for method chaining
Source code in pyiceberg/table/update/snapshot.py
remove_tag(tag_name)
¶
Remove a tag.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tag_name
|
str
|
name of tag to remove |
required |
Returns: This for method chaining