This is a method for the dplyr::compute()
generic.
For a duckplyr frame,
compute()
executes a query but stores it in a (temporary) table,
or in a Parquet or CSV file.
The result is a duckplyr frame that can be used with subsequent dplyr verbs.
# S3 method for class 'duckplyr_df'
compute(
x,
...,
prudence = NULL,
name = NULL,
schema_name = NULL,
temporary = TRUE
)
A duckplyr frame.
Arguments passed on to methods
Memory protection, controls if DuckDB may convert intermediate results in DuckDB-managed memory to data frames in R memory.
"lavish"
: regardless of size,
"stingy"
: never,
"thrifty"
: up to a maximum size of 1 million cells.
The default is to inherit from the input.
This argument is provided here only for convenience.
The same effect can be achieved by forwarding the output to as_duckdb_tibble()
with the desired prudence.
See vignette("prudence")
for more information.
The name of the table to store the result in.
The schema to store the result in, defaults to the current schema.
Set to FALSE
to store the result in a permanent table.
A duckplyr frame.
library(duckplyr)
df <- duckdb_tibble(x = c(1, 2))
df <- mutate(df, y = 2)
explain(df)
#> ┌───────────────────────────┐
#> │ PROJECTION │
#> │ ──────────────────── │
#> │ x │
#> │ y │
#> │ │
#> │ ~2 Rows │
#> └─────────────┬─────────────┘
#> ┌─────────────┴─────────────┐
#> │ R_DATAFRAME_SCAN │
#> │ ──────────────────── │
#> │ Text: data.frame │
#> │ Projections: x │
#> │ │
#> │ ~2 Rows │
#> └───────────────────────────┘
df <- compute(df)
explain(df)
#> ┌───────────────────────────┐
#> │ SEQ_SCAN │
#> │ ──────────────────── │
#> │ Table: │
#> │ duckplyr_SwlKLUUEdL │
#> │ │
#> │ Type: Sequential Scan │
#> │ │
#> │ Projections: │
#> │ x │
#> │ y │
#> │ │
#> │ ~2 Rows │
#> └───────────────────────────┘