Try Opteryx

VERSION AS OF (Time Travel)

The VERSION AS OF clause reads a catalog-backed table as of a specific snapshot id, rather than a timestamp. VERSION AS OF PREVIOUS reads the snapshot immediately before the current one, without you having to look up its id or commit time first.

Syntax

SELECT ...
  FROM <table_name> VERSION AS OF <snapshot_id>
 WHERE ...;

SELECT ...
  FROM <table_name> VERSION AS OF PREVIOUS
 WHERE ...;

Parameters

  • <table_name> — the catalog-backed table to query as of the given snapshot.
  • <snapshot_id> — a non-negative whole number identifying a snapshot, as reported by SHOW SNAPSHOTS FOR. 0 is reserved and is refused if you type it literally — use PREVIOUS instead.
  • PREVIOUS — the snapshot that is the parent of the current one. Resolved from the catalog at query time; you never need to know its id or timestamp.

Examples

Query a Specific Snapshot

SELECT * FROM my_workspace.sales.orders VERSION AS OF 1755000000000;

Query the Version Before the Current One

SELECT * FROM my_workspace.sales.orders VERSION AS OF PREVIOUS;

Find a Snapshot Id, Then Read It

SHOW SNAPSHOTS FOR my_workspace.sales.orders;

SELECT * FROM my_workspace.sales.orders VERSION AS OF 1755000000000;

Notes

  • Requires a catalog-backed table with a commit log — the same requirement as TIMESTAMP AS OF; a plain filesystem/Parquet connection has no snapshots to travel through.
  • VERSION AS OF 0 is always refused, whether or not 0 happens to be a real snapshot id — it is reserved so PREVIOUS has an unambiguous internal form to resolve.
  • PREVIOUS has no n-back form (there is no PREVIOUS 2); it always means exactly one snapshot back from current.
  • PREVIOUS fails if the current snapshot has no parent (the table's first snapshot) or if the parent has since been reclaimed — see Snapshot Reclamation. Both are query errors, not empty results.
  • Resolving PREVIOUS only ever touches the current snapshot and the one before it — it does not read the table's full commit history, unlike SHOW SNAPSHOTS FOR.

See Also