Stores a dplyr pipeline in the lake as a SQL view: the query runs fresh every time the view is read, so it always reflects the current data. Views live in the DuckLake catalog itself, which makes them a good home for shared business logic – a Python or SQL client of the same lake sees exactly the same definition.
Arguments
- .data
A lazy table (a dplyr pipeline built on
get_ducklake_table()). Not a data frame: a view stores a query, not data – usecreate_table()to store data.- view_name
Name for the view.
- replace
Replace an existing view of the same name (default TRUE).
Details
Read a view back with get_ducklake_table(), which works for views and
tables alike, and keep piping dplyr verbs onto it. Like tables, views
are versioned: dropping or replacing one is a snapshot like any other.
See also
drop_view(), list_ducklake_tables(),
replace_table() to materialize a pipeline as data instead.
Other table operations:
add_data_files(),
create_table(),
drop_view(),
ducklake_exec(),
get_ducklake_table(),
get_metadata_table(),
list_ducklake_tables(),
replace_table(),
show_ducklake_query()
Examples
if (FALSE) { # \dontrun{
# Encapsulate filtering logic the whole team should share
get_ducklake_table("adsl") |>
filter(SAFFL == "Y") |>
select(USUBJID, TRT01A, AGE) |>
create_view("v_safety_population")
# Reads run the stored query against current data
get_ducklake_table("v_safety_population") |> collect()
} # }
