Expiring snapshots

You can expire snapshots of an Iceberg table using an ALTER TABLE query. You should periodically expire snapshots to delete data files that are no longer needed, and reduce the size of table metadata.

Each write to an Iceberg table creates a new snapshot, or version, of a table. You can use snapshots for time-travel queries, or to roll back a table to a valid snapshot. Snapshots accumulate until they are expired by the expire_snapshots operation.
  1. Enter a query to expire snapshots older than the following timestamp: '2021-12-09 05:39:18.689000000'
    ALTER TABLE test_table EXECUTE EXPIRE_SNAPSHOTS('2021-12-09 05:39:18.689000000');
  2. Enter a query to expire snapshots having between December 10, 2022 and November 8, 2023.
    ALTER TABLE test_table EXECUTE EXPIRE_SNAPSHOTS BETWEEN ('2022-12-10 00:00:00.000000000') AND ('2023-11-08 00:00:00.000000000');