Commit 4a13e74
feat: setTransactionRetentionDuration (delta-io#1013)
feat: add SetTransaction retention duration filtering
## What changes are proposed in this pull request?
This PR implements the `delta.setTransactionRetentionDuration` table
property in delta-kernel-rs, which allows filtering out expired
transaction identifiers based on their `lastUpdated` timestamp. This
feature helps prevent unbounded growth of transaction logs and reduces
checkpoint file sizes.
### Key changes:
1. **Transaction filtering during log replay**: Added retention
timestamp filtering to `SetTransactionVisitor` to skip transactions
older than the retention duration
2. **Checkpoint writing**: Updated `CheckpointVisitor` to exclude
expired transactions when creating checkpoints
3. **Backward compatibility**: Transactions without `lastUpdated` field
are preserved forever (never expire)
4. **Consistent behavior**: The same retention logic is applied in both
checkpoint writing and batch transaction reading operations
### Implementation details:
- Modified `SetTransactionVisitor` to accept an optional retention
timestamp
- Updated `CheckpointLogReplayProcessor` to calculate and propagate
transaction retention timestamps
- Enhanced `CheckpointVisitor` to filter transactions based on retention
during checkpoint creation
- Single transaction lookups (`get_app_id_version`) intentionally do
filter to
- Batch operations (future `get_all_app_id_versions`, checkpointing) do
filter expired transactions
## How was this change tested?
Added comprehensive unit tests covering:
1. **Checkpoint writing tests** (`checkpoint::log_replay::tests`):
- `test_checkpoint_visitor_txn_retention`: Verifies individual
transaction filtering with various timestamp scenarios
- `test_checkpoint_actions_iter_with_txn_retention`: Tests transaction
filtering across multiple batches during checkpoint creation
2. **Transaction reading tests** (`actions::set_transaction::tests`):
- `test_visitor_retention_with_null_last_updated`: Ensures transactions
without `lastUpdated` are never filtered
- Modified existing tests to support the new retention timestamp
parameter
3. **Test scenarios covered**:
- Transactions with `lastUpdated <= retention_timestamp` are filtered
out
- Transactions with `lastUpdated = None` are always kept (backward
compatibility)
- Boundary condition: transactions exactly at retention timestamp are
filtered
- Cross-batch behavior in checkpoint processing
- Verification that filtered transactions are excluded from checkpoint
files
All tests pass with `cargo t --all-features --all-targets`.
---------
Co-authored-by: Ryan Johnson <scovich@users.noreply.github.com>
Co-authored-by: Zach Schuermann <zachary.zvs@gmail.com>1 parent 72b1705 commit 4a13e74
10 files changed
Lines changed: 257 additions & 20 deletions
File tree
- kernel
- src
- actions
- checkpoint
- tests/data/app-txn-with-last-updated/_delta_log
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
23 | 24 | | |
24 | | - | |
25 | | - | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
26 | 31 | | |
27 | 32 | | |
28 | 33 | | |
| |||
34 | 39 | | |
35 | 40 | | |
36 | 41 | | |
| 42 | + | |
37 | 43 | | |
38 | | - | |
| 44 | + | |
39 | 45 | | |
40 | 46 | | |
41 | 47 | | |
| |||
46 | 52 | | |
47 | 53 | | |
48 | 54 | | |
| 55 | + | |
49 | 56 | | |
50 | | - | |
| 57 | + | |
| 58 | + | |
51 | 59 | | |
52 | 60 | | |
53 | 61 | | |
| |||
91 | 99 | | |
92 | 100 | | |
93 | 101 | | |
| 102 | + | |
94 | 103 | | |
95 | 104 | | |
| 105 | + | |
96 | 106 | | |
97 | 107 | | |
98 | 108 | | |
| |||
108 | 118 | | |
109 | 119 | | |
110 | 120 | | |
111 | | - | |
112 | | - | |
| 121 | + | |
| 122 | + | |
113 | 123 | | |
114 | 124 | | |
115 | 125 | | |
| |||
165 | 175 | | |
166 | 176 | | |
167 | 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 | + | |
168 | 219 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
301 | 301 | | |
302 | 302 | | |
303 | 303 | | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
304 | 307 | | |
305 | 308 | | |
306 | 309 | | |
307 | 310 | | |
308 | | - | |
| 311 | + | |
309 | 312 | | |
310 | 313 | | |
311 | 314 | | |
| 315 | + | |
312 | 316 | | |
313 | 317 | | |
314 | 318 | | |
| |||
353 | 357 | | |
354 | 358 | | |
355 | 359 | | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
356 | 368 | | |
357 | 369 | | |
358 | 370 | | |
| |||
0 commit comments