View a markdown version of this page

Time travel queries on Iceberg tables - Amazon Athena

Time travel queries on Iceberg tables

To read an Iceberg table as of an earlier snapshot, follow the table name with AT (VERSION => snapshot_id). To read it as it was at a point in time, use AT (TIMESTAMP => timestamp). The query reads the snapshot that was current at that time.

To list the snapshots of a table, with their IDs and commit times, call iceberg_snapshots('database.table').

Syntax

table [ [ AS ] alias ] AT ( VERSION => snapshot_id ) table [ [ AS ] alias ] AT ( TIMESTAMP => timestamp )

Examples

For a description of the sample tables that the examples on this page use, see SELECT statement in DuckDB.

The following SQL query counts the rows of the first snapshot of orders_iceberg, before the third order was added.

SELECT count(*) AS orders FROM sales_db.orders_iceberg AT ( VERSION => 1294122691170353594 )

The query returns the following result.

orders

2

The following SQL query reads the table as it was at a time between its two snapshots. The alias comes before AT.

SELECT o.order_id, o.customer FROM sales_db.orders_iceberg AS o AT ( TIMESTAMP => TIMESTAMP '2026-11-24 05:28:21' ) ORDER BY o.order_id

The query returns the following results.

order_id customer

1

alice

2

bob

Considerations

Put a table alias before AT, as in FROM orders AS o AT (VERSION => 1234). An alias after AT (...) is a syntax error.

Time travel to an Iceberg branch or tag is not supported.

Differences from Athena engine version 3

Athena engine version 3 reads an earlier snapshot with FOR VERSION AS OF snapshot_id. In DuckDB, write AT (VERSION => snapshot_id).

Athena engine version 3 reads a table as of a point in time with FOR TIMESTAMP AS OF timestamp. In DuckDB, write AT (TIMESTAMP => timestamp).

Athena engine version 3 lists snapshots from the "table$snapshots" metadata table. In DuckDB, call iceberg_snapshots('database.table').