A domain-agnostic R6 class that provides an interface to a folder-based data storage system using DuckDB for in-memory SQL operations and parquet files for efficient on-disk persistence. This class can be inherited by domain-specific database classes.
Public fields
connectionDBI connection object to an in-memory DuckDB database
pathCharacter string path to the data folder
default_formatDefault file format for new tables
writeoptsDefault write options for DuckDB
Methods
Method new()
Initialize a new parquet_duckdb object
Usage
parquet_duckdb$new(
path,
default_format = c("parquet", "csv"),
extensions = character(0)
)Method attach_table()
Attach a table from parquet/CSV file as a temporary table in DuckDB
Method with_tables()
Execute a function with specified tables attached, handling attach/detach automatically. If a table is already attached in the DuckDB instance, it won't be re-attached or detached.
Method fetch()
Fetch data from a table
Method delete_from()
Delete rows from a table
Method commit()
Commit data using overwrite, append, or upsert modes. Handles autoincrement, key identity columns, and list-to-MAP conversion.
Arguments
xData frame to commit. If character, in-duckdb-memory table.
table_nameCharacter string table name
key_colsCharacter vector of columns that define uniqueness. If missing, use all columns starting with
id_autoincrement_colsCharacter vector of column names to auto-increment
map_colsCharacter vector of columns to convert to MAP format
methodCharacter, one of "overwrite", "append", "upsert" (upsert being an update for existing rows, and insert for new rows)
Method print()
Print method for parquet_duckdb
Returns
self (invisibly)
param x Data frame to commit. If character, in-duckdb-memory table.
param table_name Character string table name
param autoincrement_cols Character vector of column names to auto-increment
param map_cols Character vector of columns to convert to MAP format
return Invisible NULL (called for side effects)
param x Data frame to commit. If character, in-duckdb-memory table.
param table_name Character string table name
param autoincrement_cols Character vector of column names to auto-increment
param map_cols Character vector of columns to convert to MAP format
return Invisible NULL (called for side effects)
param x Data frame to commit. If character, in-duckdb-memory table.
param table_name Character string table name
param key_cols Character vector of columns that define uniqueness. If missing,
use all columns starting with id_
param autoincrement_cols Character vector of column names to auto-increment
param map_cols Character vector of columns to convert to MAP format
return Invisible NULL (called for side effects)