Skip to content

Commit fb5985b

Browse files
committed
Merge branch 'main' of github.com:apache/iceberg-python into fd-ray
2 parents 338e6fd + e32ba2a commit fb5985b

File tree

3 files changed

+2277
-1712
lines changed

3 files changed

+2277
-1712
lines changed

mkdocs/docs/api.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1350,6 +1350,62 @@ with table.manage_snapshots() as ms:
13501350
ms.create_branch(snapshot_id1, "Branch_A").create_tag(snapshot_id2, "tag789")
13511351
```
13521352

1353+
### Tags
1354+
1355+
Tags are named references to snapshots that are immutable. They can be used to mark important snapshots for long-term retention or to reference specific table versions.
1356+
1357+
Create a tag pointing to a specific snapshot:
1358+
1359+
```python
1360+
# Create a tag with default retention
1361+
table.manage_snapshots().create_tag(
1362+
snapshot_id=snapshot_id,
1363+
tag_name="v1.0.0"
1364+
).commit()
1365+
1366+
# Create a tag with custom max reference age
1367+
table.manage_snapshots().create_tag(
1368+
snapshot_id=snapshot_id,
1369+
tag_name="v1.0.0",
1370+
max_ref_age_ms=604800000 # 7 days
1371+
).commit()
1372+
```
1373+
1374+
Remove an existing tag:
1375+
1376+
```python
1377+
table.manage_snapshots().remove_tag("v1.0.0").commit()
1378+
```
1379+
1380+
### Branching
1381+
1382+
Branches are mutable named references to snapshots that can be updated over time. They allow for independent lineages of table changes, enabling use cases like development branches, testing environments, or parallel workflows.
1383+
1384+
Create a branch pointing to a specific snapshot:
1385+
1386+
```python
1387+
# Create a branch with default settings
1388+
table.manage_snapshots().create_branch(
1389+
snapshot_id=snapshot_id,
1390+
branch_name="dev"
1391+
).commit()
1392+
1393+
# Create a branch with retention policies
1394+
table.manage_snapshots().create_branch(
1395+
snapshot_id=snapshot_id,
1396+
branch_name="dev",
1397+
max_ref_age_ms=604800000, # Max age of the branch reference (7 days)
1398+
max_snapshot_age_ms=259200000, # Max age of snapshots to keep (3 days)
1399+
min_snapshots_to_keep=10 # Minimum number of snapshots to retain
1400+
).commit()
1401+
```
1402+
1403+
Remove an existing branch:
1404+
1405+
```python
1406+
table.manage_snapshots().remove_branch("dev").commit()
1407+
```
1408+
13531409
## Table Maintenance
13541410

13551411
PyIceberg provides table maintenance operations through the `table.maintenance` API. This provides a clean interface for performing maintenance tasks like snapshot expiration.

0 commit comments

Comments
 (0)