Perform Iceberg time travel queries using both snapshot ID and timestamp syntax across Spark and Trino

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. Identify available snapshots by querying the metadata table: SELECT snapshot_id, committed_at, operation FROM <catalog>.<db>.<table>.snapshots ORDER BY committed_at
  2. In Spark, query by snapshot ID using the VERSION AS OF clause: SELECT * FROM <catalog>.<db>.<table> VERSION AS OF <snapshot_id>; query by timestamp using TIMESTAMP AS OF: SELECT * FROM <catalog>.<db>.<table> TIMESTAMP AS OF '2024-01-15 12:00:00'
  3. In Trino, use the FOR VERSION AS OF and FOR TIMESTAMP AS OF syntax: SELECT * FROM <catalog>.<schema>.<table> FOR VERSION AS OF <snapshot_id> and SELECT * FROM <catalog>.<schema>.<table> FOR TIMESTAMP AS OF TIMESTAMP '2024-01-15 12:00:00 UTC'
  4. Use time travel for audit or debugging: compare current state vs a past snapshot with EXCEPT or by joining on a key column; useful for identifying which rows changed between two snapshots
  5. Understand snapshot retention: time travel only works for snapshots that have not been expired; after running expire_snapshots, queries referencing expired snapshot IDs or timestamps before the oldest retained snapshot will fail

Known gotchas

Related routes

Query historical Iceberg table state using snapshot-id and as-of-timestamp time-travel syntax
iceberg.apache.org · 5 steps · unrated
Query federated data across an Iceberg catalog and a PostgreSQL connector in Trino with a cross-catalog join
trino.io · 5 steps · unrated
Configure Iceberg REST catalog with a remote catalog server and connect Spark and Trino clients to it
iceberg.apache.org · 5 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