Returns a lazy reference to a table in the attached DuckLake. Like
dplyr::tbl(), nothing is read until you collect(): build up your
filter()/mutate()/summarise() pipeline first and DuckDB executes it
as a single query, only pulling the rows you asked for into R.
Value
A lazy table (class tbl_ducklake) that works with dplyr verbs.
The table name is stored in the ducklake_table_name attribute.
See also
create_table() to create tables, get_ducklake_table_asof()
and get_ducklake_table_version() for time-travel reads.
Other table operations:
add_data_files(),
create_schema(),
create_table(),
create_view(),
drop_schema(),
drop_view(),
ducklake_exec(),
get_metadata_table(),
list_ducklake_tables(),
replace_table(),
show_ducklake_query()
Examples
lake_dir <- tempfile("cars_lake_")
dir.create(lake_dir)
attach_ducklake("cars_lake", lake_path = lake_dir)
create_table(mtcars, "cars")
# Query lazily with dplyr, then collect
get_ducklake_table("cars") |>
dplyr::filter(cyl > 4) |>
dplyr::summarise(avg_mpg = mean(mpg), .by = cyl) |>
dplyr::collect()
#> Warning: Missing values are always removed in SQL aggregation functions.
#> Use `na.rm = TRUE` to silence this warning
#> This warning is displayed once every 8 hours.
#> # A tibble: 2 × 2
#> cyl avg_mpg
#> <dbl> <dbl>
#> 1 6 19.7
#> 2 8 15.1
detach_ducklake("cars_lake", shutdown = TRUE)
unlink(lake_dir, recursive = TRUE)
