Skip to contents

DuckLake keeps all of its bookkeeping – snapshots, table schemas, data file locations, and more – in ordinary tables inside the catalog database. This function gives you a lazy reference to any of them, which is handy for auditing and for understanding how your lake evolves.

Usage

get_metadata_table(tbl_name, ducklake_name = NULL)

Arguments

tbl_name

Character string, name of the metadata table to retrieve (e.g., "ducklake_snapshot").

ducklake_name

Character string, name of the ducklake database (optional, defaults to the currently active ducklake).

Value

A lazy table that works with dplyr verbs.

Details

Commonly useful tables include ducklake_snapshot (one row per snapshot), ducklake_table (registered tables), and ducklake_data_file (the Parquet files backing each table). The full list is in the DuckLake specification.

Examples

lake_dir <- tempfile("meta_lake_")
dir.create(lake_dir)
attach_ducklake("meta_lake", lake_path = lake_dir)
create_table(mtcars, "cars")

# Every snapshot ever taken
get_metadata_table("ducklake_snapshot") |> dplyr::collect()
#> # A tibble: 2 × 5
#>   snapshot_id snapshot_time       schema_version next_catalog_id next_file_id
#>         <dbl> <dttm>                       <dbl>           <dbl>        <dbl>
#> 1           0 2026-09-17 21:43:05              0               1            0
#> 2           1 2026-09-17 21:43:05              1               2            1

# Which Parquet files back the lake?
get_metadata_table("ducklake_data_file") |>
  dplyr::select(data_file_id, path) |>
  dplyr::collect()
#> # A tibble: 1 × 2
#>   data_file_id path                                                 
#>          <dbl> <chr>                                                
#> 1            0 ducklake-01a0b152-c02f-7d31-ac09-c292cbab5d31.parquet

detach_ducklake("meta_lake", shutdown = TRUE)
unlink(lake_dir, recursive = TRUE)