Commit b44cfa9
refactor: consolidate snapshot expiration into MaintenanceTable (apache#2143)
<!--
Thanks for opening a pull request!
-->
<!-- Closes apache#2150 -->
# Rationale for this change
- Consolidates snapshot expiration functionality from the standalone
`ExpireSnapshots` class into the `MaintenanceTable` class for a unified
maintenance API.
- Resolves planned work left over from apache#1880, and closes
apache#2142
- Achieves feature and API parity with the Java implementation for
snapshot retention and table maintenance.
# Features & Enhancements
- Introduces `table.maintenance.expire_snapshots()` as the unified entry
point for snapshot expiration and future maintenance operations.
- Retains the existing `ExpireSnapshots` implementation internally. The
`expire_snapshots()` method on `MaintenanceTable` now returns an
`ExpireSnapshots` object, preserving transaction semantics and
supporting context manager usage:
```python
with table.maintenance.expire_snapshots() as expire_snapshots:
expire_snapshots.by_id(1)
expire_snapshots.by_id(2)
```
- Focuses this PR on refactoring and documentation improvements, while
maintaining compatibility with the prior `ExpireSnapshots` interface.
- Sets a foundation for future expansion of the `MaintenanceTable`
abstraction to encapsulate additional maintenance operations.
# Bug Fixes & Cleanups
- **ManageSnapshots Cleanup
([apache#2151](apache#2151
- Removes an unrelated instance variable from the `ManageSnapshots`
class, aligning with the Java reference implementation.
# Testing & Documentation
- **Testing:**
- Tested the new API interface including:
- Expiration by ID
- Protection of branch/tag snapshots
- **Documentation:**
- Added and updated documentation to describe:
- API usage examples
Preview:
<img width="1686" height="1015" alt="Screenshot 2025-08-11 at 1 37
04 PM"
src="https://github.com/user-attachments/assets/f469f3fc-b4b1-4ec9-b1ca-b9185e22643e"
/>
# Are these changes tested?
Yes. All changes are tested.~, with this PR predicated on the final
changes from apache#1200.~ This work builds on the framework introduced by
@jayceslesar in apache#1200 for the `MaintenanceTable`.
# Are there any user-facing changes?
---
**Closes:**
- Closes apache#2151
- Closes apache#2142
---------
Co-authored-by: Fokko Driesprong <fokko@apache.org>
Co-authored-by: Kevin Liu <kevin.jq.liu@gmail.com>1 parent 5956b24 commit b44cfa9
File tree
5 files changed
+108
-17
lines changed- mkdocs/docs
- pyiceberg/table
- update
- tests/table
5 files changed
+108
-17
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1287 | 1287 | | |
1288 | 1288 | | |
1289 | 1289 | | |
| 1290 | + | |
| 1291 | + | |
| 1292 | + | |
| 1293 | + | |
| 1294 | + | |
| 1295 | + | |
| 1296 | + | |
| 1297 | + | |
| 1298 | + | |
| 1299 | + | |
| 1300 | + | |
| 1301 | + | |
| 1302 | + | |
| 1303 | + | |
| 1304 | + | |
| 1305 | + | |
| 1306 | + | |
| 1307 | + | |
| 1308 | + | |
| 1309 | + | |
| 1310 | + | |
| 1311 | + | |
| 1312 | + | |
| 1313 | + | |
| 1314 | + | |
| 1315 | + | |
| 1316 | + | |
| 1317 | + | |
| 1318 | + | |
| 1319 | + | |
| 1320 | + | |
| 1321 | + | |
| 1322 | + | |
| 1323 | + | |
| 1324 | + | |
| 1325 | + | |
| 1326 | + | |
| 1327 | + | |
| 1328 | + | |
| 1329 | + | |
| 1330 | + | |
1290 | 1331 | | |
1291 | 1332 | | |
1292 | 1333 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
80 | 80 | | |
81 | 81 | | |
82 | 82 | | |
| 83 | + | |
83 | 84 | | |
84 | 85 | | |
85 | 86 | | |
| |||
115 | 116 | | |
116 | 117 | | |
117 | 118 | | |
118 | | - | |
| 119 | + | |
119 | 120 | | |
120 | 121 | | |
121 | 122 | | |
| |||
1086 | 1087 | | |
1087 | 1088 | | |
1088 | 1089 | | |
| 1090 | + | |
| 1091 | + | |
| 1092 | + | |
| 1093 | + | |
| 1094 | + | |
| 1095 | + | |
| 1096 | + | |
| 1097 | + | |
| 1098 | + | |
1089 | 1099 | | |
1090 | 1100 | | |
1091 | 1101 | | |
| |||
1258 | 1268 | | |
1259 | 1269 | | |
1260 | 1270 | | |
1261 | | - | |
1262 | | - | |
1263 | | - | |
1264 | | - | |
1265 | 1271 | | |
1266 | 1272 | | |
1267 | 1273 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
907 | 907 | | |
908 | 908 | | |
909 | 909 | | |
910 | | - | |
911 | | - | |
| 910 | + | |
912 | 911 | | |
913 | 912 | | |
914 | 913 | | |
| |||
953 | 952 | | |
954 | 953 | | |
955 | 954 | | |
956 | | - | |
| 955 | + | |
957 | 956 | | |
958 | 957 | | |
959 | 958 | | |
| |||
974 | 973 | | |
975 | 974 | | |
976 | 975 | | |
977 | | - | |
| 976 | + | |
978 | 977 | | |
979 | 978 | | |
980 | 979 | | |
| |||
986 | 985 | | |
987 | 986 | | |
988 | 987 | | |
989 | | - | |
| 988 | + | |
990 | 989 | | |
991 | 990 | | |
992 | | - | |
| 991 | + | |
993 | 992 | | |
994 | 993 | | |
995 | 994 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
46 | | - | |
| 46 | + | |
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
| |||
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
69 | | - | |
| 69 | + | |
70 | 70 | | |
71 | 71 | | |
72 | 72 | | |
| |||
98 | 98 | | |
99 | 99 | | |
100 | 100 | | |
101 | | - | |
| 101 | + | |
102 | 102 | | |
103 | 103 | | |
104 | 104 | | |
| |||
114 | 114 | | |
115 | 115 | | |
116 | 116 | | |
117 | | - | |
| 117 | + | |
118 | 118 | | |
119 | 119 | | |
120 | 120 | | |
| |||
152 | 152 | | |
153 | 153 | | |
154 | 154 | | |
155 | | - | |
| 155 | + | |
156 | 156 | | |
157 | 157 | | |
158 | 158 | | |
| |||
215 | 215 | | |
216 | 216 | | |
217 | 217 | | |
218 | | - | |
| 218 | + | |
219 | 219 | | |
220 | 220 | | |
221 | 221 | | |
| |||
0 commit comments