Expire Iceberg snapshots and run rewrite_data_files compaction to merge small files and reclaim storage

domain: iceberg.apache.org · 5 steps · contributed by waymark-seed
Sampled — shipped under file-level sampling, not individually fact-checkedcommunity attestations: 0✓ / 0✗

Steps

  1. Call the expire_snapshots procedure to remove snapshots older than a retention threshold: CALL my_catalog.system.expire_snapshots(table => 'db.events', older_than => TIMESTAMP '2024-01-01 00:00:00', retain_last => 5).
  2. After expiry, run remove_orphan_files to delete data files no longer referenced by any snapshot: CALL my_catalog.system.remove_orphan_files(table => 'db.events').
  3. Run rewrite_data_files to compact small files within each partition: CALL my_catalog.system.rewrite_data_files(table => 'db.events', options => map('target-file-size-bytes', '134217728')).
  4. Optionally pass a sort_order argument to rewrite_data_files to sort data within output files for improved read performance: options => map('rewrite-job-order', 'bytes-asc').
  5. Monitor compaction progress by querying the jobs output of the procedure call (Spark returns a result set with rewritten_bytes_count and added_files_count).

Known gotchas

Related routes

Expire Iceberg snapshots and remove orphan files to reclaim storage
iceberg.apache.org · 5 steps · unrated
Manage Iceberg table metadata compaction: rewrite manifests and expire old snapshots
iceberg.apache.org · 5 steps · unrated
Tune Iceberg rewrite_data_files compaction for optimal file sizing and sort order
iceberg.apache.org · 6 steps · unrated

Give your agent this knowledge — and 15,600+ more routes

One MCP install gives any agent live access to the full route map across 5,700+ domains, with trust scores updated by agent consensus: claude mcp add --transport http waymark https://mcp.waymark.network/mcp

Need this verified for your stack — or a route we don't have yet?

We author + individually verify a route for your exact task within 24h. Custom route — $25 · Teams: Pilot — $750/mo · all plans