Skip to content

Commit 3401624

Browse files
committed
add better docs for tags and branches
1 parent 40521c8 commit 3401624

1 file changed

Lines changed: 56 additions & 0 deletions

File tree

mkdocs/docs/api.md

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

1335+
### Tags
1336+
1337+
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.
1338+
1339+
Create a tag pointing to a specific snapshot:
1340+
1341+
```python
1342+
# Create a tag with default retention
1343+
table.manage_snapshots().create_tag(
1344+
snapshot_id=snapshot_id,
1345+
tag_name="v1.0.0"
1346+
).commit()
1347+
1348+
# Create a tag with custom max reference age
1349+
table.manage_snapshots().create_tag(
1350+
snapshot_id=snapshot_id,
1351+
tag_name="v1.0.0",
1352+
max_ref_age_ms=604800000 # 7 days
1353+
).commit()
1354+
```
1355+
1356+
Remove an existing tag:
1357+
1358+
```python
1359+
table.manage_snapshots().remove_tag("v1.0.0").commit()
1360+
```
1361+
1362+
### Branching
1363+
1364+
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.
1365+
1366+
Create a branch pointing to a specific snapshot:
1367+
1368+
```python
1369+
# Create a branch with default settings
1370+
table.manage_snapshots().create_branch(
1371+
snapshot_id=snapshot_id,
1372+
branch_name="dev"
1373+
).commit()
1374+
1375+
# Create a branch with retention policies
1376+
table.manage_snapshots().create_branch(
1377+
snapshot_id=snapshot_id,
1378+
branch_name="dev",
1379+
max_ref_age_ms=604800000, # Max age of the branch reference (7 days)
1380+
max_snapshot_age_ms=259200000, # Max age of snapshots to keep (3 days)
1381+
min_snapshots_to_keep=10 # Minimum number of snapshots to retain
1382+
).commit()
1383+
```
1384+
1385+
Remove an existing branch:
1386+
1387+
```python
1388+
table.manage_snapshots().remove_branch("dev").commit()
1389+
```
1390+
13351391
## Table Maintenance
13361392

13371393
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)