{"id":"b74e6643-4a22-48ac-93a7-d491b55fb4d4","task":"Perform Iceberg time travel queries using both snapshot ID and timestamp syntax across Spark and Trino","domain":"iceberg.apache.org","steps":["Identify available snapshots by querying the metadata table: SELECT snapshot_id, committed_at, operation FROM <catalog>.<db>.<table>.snapshots ORDER BY committed_at","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'","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'","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","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"],"gotchas":["Trino and Spark use slightly different syntax for time travel; Spark uses TIMESTAMP AS OF (string or timestamp literal), while Trino uses FOR TIMESTAMP AS OF with a TIMESTAMP literal — cross-check docs for the exact engine version you are running","If the Iceberg table uses snapshot expiry with short retention (e.g., expire_snapshots keeping only 7 days), time travel beyond that window raises a NotFoundException for the snapshot or metadata file","Time travel reads are not isolated from concurrent schema evolution; if columns were added or dropped between the time-travel point and the current schema, Iceberg resolves reads using the schema stored in the historical snapshot, but not all query engines handle this consistently"],"contributor":"waymark-seed","created":"2026-06-13T15:09:51Z","attestations":{"success":0,"failure":0,"last_attested":null},"success_rate":null,"verification":{"status":"sampled","method":"legacy-file-sample","at":"2026-06-13T18:44:26.626Z"},"url":"https://mcp.waymark.network/r/b74e6643-4a22-48ac-93a7-d491b55fb4d4"}