Removes old snapshots from the DuckLake catalog. Expiring snapshots gives up the ability to time-travel to them, and schedules the data files that only they referenced for deletion.
Arguments
- ducklake_name
Name of the attached DuckLake catalog. If
NULL, the current database is used.- older_than
Expire all snapshots older than this timestamp (POSIXct or character in ISO 8601 format). POSIXct values are converted to UTC, which is how DuckLake records snapshot times; character values must already be UTC. At least one of
older_thanorversionsmust be provided.- versions
Integer vector of specific snapshot ids to expire (see
list_table_snapshots()).- dry_run
If
TRUE, only lists the snapshots that would be expired without expiring them.
Details
Expiring snapshots does not delete any files by itself: files that are no
longer referenced are merely scheduled for deletion. Run
cleanup_old_files() afterwards to reclaim the storage, or let
checkpoint_ducklake() handle both steps.
The most recent snapshot can never be expired.
Examples
if (FALSE) { # \dontrun{
# Preview what a one-week retention policy would remove
expire_snapshots(older_than = Sys.time() - 7 * 24 * 60 * 60, dry_run = TRUE)
# Expire it for real, then reclaim the storage
expire_snapshots(older_than = Sys.time() - 7 * 24 * 60 * 60)
cleanup_old_files(cleanup_all = TRUE)
# Expire two specific snapshots
expire_snapshots(versions = c(2, 3))
} # }
