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
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 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 |
|
_commit()
¶
_remove_ref_snapshot(ref_name)
¶
Remove a snapshot ref.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ref_name
|
str
|
branch / tag name to remove |
required |
Stages the updates and requirements for the remove-snapshot-ref. Returns This method for chaining
Source code in pyiceberg/table/update/snapshot.py
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 |
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
_DeleteFiles
¶
Bases: _SnapshotProducer['_DeleteFiles']
Will delete manifest entries from the current snapshot based on the predicate.
This will produce a DELETE snapshot
Data files were removed and their contents logically deleted and/or delete files were added to delete rows.
From the specification
Source code in pyiceberg/table/update/snapshot.py
308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 |
|
_compute_deletes
cached
property
¶
Computes all the delete operation and cache it when nothing changes.
Returns:
Type | Description |
---|---|
List[ManifestFile]
|
|
List[ManifestEntry]
|
|
bool
|
|
files_affected
property
¶
Indicate if any manifest-entries can be dropped.
rewrites_needed
property
¶
Indicate if data files need to be rewritten.
_FastAppendFiles
¶
Bases: _SnapshotProducer['_FastAppendFiles']
Source code in pyiceberg/table/update/snapshot.py
_deleted_entries()
¶
To determine if we need to record any deleted manifest entries.
In case of an append, nothing is deleted.
_existing_manifests()
¶
To determine if there are any existing manifest files.
A fast append will add another ManifestFile to the ManifestList. All the existing manifest files are considered existing.
Source code in pyiceberg/table/update/snapshot.py
_MergeAppendFiles
¶
Bases: _FastAppendFiles
Source code in pyiceberg/table/update/snapshot.py
_process_manifests(manifests)
¶
To perform any post-processing on the manifests before writing them to the new snapshot.
In _MergeAppendFiles, we merge manifests based on the target size and the minimum count to merge if automatic merge is enabled.
Source code in pyiceberg/table/update/snapshot.py
_OverwriteFiles
¶
Bases: _SnapshotProducer['_OverwriteFiles']
Overwrites data from the table. This will produce an OVERWRITE snapshot.
Data and delete files were added and removed in a logical overwrite operation.
Source code in pyiceberg/table/update/snapshot.py
_deleted_entries()
¶
To determine if we need to record any deleted entries.
With a full overwrite all the entries are considered deleted. With partial overwrites we have to use the predicate to evaluate which entries are affected.
Source code in pyiceberg/table/update/snapshot.py
_existing_manifests()
¶
Determine if there are any existing manifest files.
Source code in pyiceberg/table/update/snapshot.py
_SnapshotProducer
¶
Bases: UpdateTableMetadata[U]
, Generic[U]
Source code in pyiceberg/table/update/snapshot.py
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 |
|
_process_manifests(manifests)
¶
To perform any post-processing on the manifests before writing them to the new snapshot.