These functions apply to duckplyr frames. They executes a query and stores the results in a flat file. The result is a duckplyr frame that can be used with subsequent dplyr verbs.
compute_parquet()
creates a Parquet file.
compute_csv()
creates a CSV file.
Usage
compute_parquet(x, path, ..., prudence = NULL, options = NULL)
compute_csv(x, path, ..., prudence = NULL, options = NULL)
Arguments
- x
A duckplyr frame.
- path
The path to store the result in.
- ...
These dots are for future extensions and must be empty.
- prudence
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. Seevignette("prudence")
for more information.- options
A list of additional options to pass to create the storage format, see https://duckdb.org/docs/data/parquet/overview#writing-to-parquet-files or https://duckdb.org/docs/data/csv/overview#writing-using-the-copy-statement for details.
Examples
library(duckplyr)
df <- data.frame(x = c(1, 2))
df <- mutate(df, y = 2)
path <- tempfile(fileext = ".parquet")
df <- compute_parquet(df, path)
explain(df)
#> ┌───────────────────────────┐
#> │ READ_PARQUET │
#> │ ──────────────────── │
#> │ Function: │
#> │ READ_PARQUET │
#> │ │
#> │ Projections: │
#> │ x │
#> │ y │
#> │ │
#> │ ~2 Rows │
#> └───────────────────────────┘