duckdb_tibble {duckplyr} | R Documentation |
duckplyr data frames
Description
Data frames backed by duckplyr have a special class, "duckplyr_df"
,
in addition to the default classes.
This ensures that dplyr methods are dispatched correctly.
For such objects,
dplyr verbs such as dplyr::mutate()
, dplyr::select()
or dplyr::filter()
will use DuckDB.
duckdb_tibble()
works like tibble::tibble()
.
as_duckdb_tibble()
converts a data frame or a dplyr lazy table to a duckplyr data frame.
This is a generic function that can be overridden for custom classes.
is_duckdb_tibble()
returns TRUE
if x
is a duckplyr data frame.
Usage
duckdb_tibble(..., .prudence = c("lavish", "thrifty", "stingy"))
as_duckdb_tibble(x, ..., prudence = c("lavish", "thrifty", "stingy"))
is_duckdb_tibble(x)
Arguments
... |
For |
x |
The object to convert or to test. |
prudence , .prudence |
Memory protection, controls if DuckDB may convert intermediate results in DuckDB-managed memory to data frames in R memory.
The default is |
Value
For duckdb_tibble()
and as_duckdb_tibble()
, an object with the following classes:
-
"prudent_duckplyr_df"
ifprudence
is not"lavish"
-
"duckplyr_df"
Classes of a tibble::tibble
For is_duckdb_tibble()
, a scalar logical.
Fine-tuning prudence
The prudence
argument can also be a named numeric vector
with at least one of cells
or rows
to limit the cells (values) and rows in the resulting data frame
after automatic materialization.
If both limits are specified, both are enforced.
The equivalent of "thrifty"
is c(cells = 1e6)
.
Examples
x <- duckdb_tibble(a = 1)
x
library(dplyr)
x %>%
mutate(b = 2)
x$a
y <- duckdb_tibble(a = 1, .prudence = "stingy")
y
try(length(y$a))
length(collect(y)$a)