> ## Documentation Index
> Fetch the complete documentation index at: https://docs.bijection.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Retention, maintenance and erasure

The Datasets installation decides which versions stay readable. It never deletes a
file: retirement and erasure remove version tags, and maintenance of the
warehouse deletes what no tag keeps.

## Table maintenance

* **Managed catalogs.** Bijection's catalog maintenance
  runs every ten minutes per warehouse. A snapshot no tag or branch has
  referenced for the longest read lease plus a few minutes is expired; the
  files only it reached are deleted with every object version; orphan files
  older than three days are removed daily. Each pass records its evidence per
  table.
* **Compaction** rewrites data, so it is compute: the writer of a synced
  dataset compacts as an ordinal of the sync's writer sequence, and your engine
  compacts the tables it writes.
* **Your own catalog.** Snapshot expiry, orphan removal and deletion of
  noncurrent object versions are your engine's job. Bijection only removes its
  tags.

### Version retention

The options of `datasets(...)` set the policy, changed only by a deploy:

| Setting | Default | Meaning |
| - | - | - |
| `versionRetentionDays` | 7 (0 to 3,650) | How long a superseded, unheld version stays readable |
| `keepVersions` | 1 (1 to 1,000) | The newest versions kept regardless of age |
| `maxHoldDays` | 30 (1 to 365) | The longest hold a holder may place |

The current version is always kept. An hourly sweep ends expired holds and
retires unheld versions past retention by removing their tag; retired versions
stay in the ledger. Holds, cuts, views and read leases keep the versions they
name.

### Run maintenance with Spark

On a catalog you bring, expire the snapshots Bijection no longer tags with
Iceberg's procedures, for example:

```sql theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
CALL lake.system.expire_snapshots(table => 'sales.orders', older_than => TIMESTAMP '2026-01-01 00:00:00', retain_last => 1);
CALL lake.system.remove_orphan_files(table => 'sales.orders');
```

Expiry never removes a snapshot a tag or branch references, so held versions
survive it. Keep at least the dataset's lease length between a tag's removal
and the expiry of its snapshot, so no read granted while it was tagged meets a
deleted file. With a versioned bucket, delete noncurrent object versions too.

### Purge erased records

A legal erasure is `ctx.call(lake.versions.erased, { dataset, number, message })`: the version
at `number` no longer holds the subject; every older retained version, and
every version computed from a redacted one, is redacted and its holds end
`redacted`. The answer lists where the redacted versions went (also
`reaches.ofErasure({ dataset, number })`). An operator redacts a version
directly with `versions.redact`. The dataset's erase counter moves forward, so a snapshot
staged before the erasure must be staged again.

When you know the native closures for that erasure, pass their
`sys.erasures` IDs in `closures`. An eraser can query
`versions.erasureImpact({ dataset, number })` for a withdrawn managed
Flink result. The response identifies the affected opaque window slots
in that version's exact inventory and the source erasure counters used
in the lookup. It returns `unavailable` when the version, inventory or
closure records are incomplete. Managed Flink evaluates a replacement
from a newly admitted cut. It can reuse surviving result files when
their rebuilt values match and their original custody covers the fresh
dependencies.

In a sealed catalog, erasure is the destruction of the affected files' keys,
at most the dataset's lease length (plus a few minutes) after the request,
whether or not the files are deleted. Rewriting files without the erased facts,
expiring snapshots and deleting objects then reclaim space. A mirror's rewritten
facts are refilled from your table; a change log records the hole as a gap. In
a plaintext catalog you bring, the erasure bound is what your maintenance
schedule achieves.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.