DataBackend for DuckDBSource:
Function which is called to re-connect in case the connection became invalid.
Data base table or view to operate on.
Data frame as returned by pragma
Returns vector of all distinct row identifiers, i.e. the contents of the primary key column.
Returns vector of all column names, including the primary key column.
Number of rows (observations).
Number of columns (variables), including the primary key column.
NAif the data does not inherits from
"tbl_sql"(i.e., it is not a real SQL data base). Returns the result of
Creates a backend for a
DataBackendDuckDB$new( data, table, primary_key, strings_as_factors = TRUE, connector = NULL )
A connection created with
DBI::dbConnect(). If constructed manually (and not via the helper function
as_duckdb_backend(), make sure that there exists an (unique) index for the key column.
Table or view to operate on.
Name of the primary key column.
Either a character vector of column names to convert to factors, or a single logical flag: if
FALSE, no column will be converted, if
TRUEall string columns (except the primary key). For conversion, the backend is queried for distinct values of the respective columns on construction and their levels are stored in
)\cr If notNULL`, a function which re-connects to the database in case the connection has become invalid. Database connections can become invalid due to timeouts or if the backend is serialized to the file system and then de-serialized again. This round trip is often performed for parallelization, e.g. to send the objects to remote workers.
DBI::dbIsValid()is called to validate the connection. The function must return just the connection, not a
dplyr::tbl()object! Note that this this function is serialized together with the backend, including possible sensitive information such as login credentials. These can be retrieved from the stored mlr3::DataBackend/mlr3::Task. To protect your credentials, it is recommended to use the secret package.
Finalizer which disconnects from the database. This is called during garbage collection of the instance.
logical(1), the return value of
Returns a slice of the data.
The rows must be addressed as vector of primary key values, columns must be referred to via column names.
Queries for rows with no matching row id and queries for columns with no matching
column name are silently ignored.
Rows are guaranteed to be returned in the same order as
rows, columns may be returned in an arbitrary order.
Duplicated row ids result in duplicated rows, duplicated column names lead to an exception.
Retrieve the first
data.table::data.table() of the first
Returns a named list of vectors of distinct values for each column
TRUE, missing values are removed from the
returned vectors of distinct values. Non-existing rows and columns are
list() of distinct values.
Returns the number of missing values per column in the specified slice of data. Non-existing rows and columns are silently ignored.
Total of missing values per column (named