Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: mlr3db
Title: Data Base Backend for 'mlr3'
Version: 0.5.0-9000
Version: 0.5.1
Authors@R:
person(given = "Michel",
family = "Lang",
Expand Down Expand Up @@ -41,4 +41,4 @@ Suggests:
Encoding: UTF-8
Config/testthat/edition: 3
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.2.2
RoxygenNote: 7.2.3
6 changes: 5 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
# mlr3db 0.5.1

- Compatibility with new duckdb version (#36).

# mlr3db 0.5.0

- Support for parquet files as Backend via DuckDB.
- New converter `as_duckdb_backend()`.
- New converter `as_duckdb_backend()`.

# mlr3db 0.4.2

Expand Down
4 changes: 2 additions & 2 deletions R/DataBackendDplyr.R
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@
#' dplyr::copy_to(con, data)
#' tbl = dplyr::tbl(con, "data")
#'
#' # Define a backend on a subset of the database
#' tbl = dplyr::select_at(tbl, setdiff(colnames(tbl), "Sepal.Width")) # do not use column "Sepal.Width"
#' # Define a backend on a subset of the database: do not use column "Sepal.Width"
#' tbl = dplyr::select_at(tbl, setdiff(colnames(tbl), "Sepal.Width"))
#' tbl = dplyr::filter(tbl, row_id %in% 1:120) # Use only first 120 rows
#' b = DataBackendDplyr$new(tbl, primary_key = "row_id")
#' print(b)
Expand Down
6 changes: 3 additions & 3 deletions R/DataBackendDuckDB.R
Original file line number Diff line number Diff line change
Expand Up @@ -134,28 +134,28 @@ DataBackendDuckDB = R6Class("DataBackendDuckDB", inherit = DataBackend, cloneabl
private$.reconnect()
assert_names(cols, type = "unique")
cols = intersect(cols, self$colnames)
order = sprintf('ORDER BY "%s"', self$primary_key)

if (is.null(rows)) {
get_query = function(col) {
sprintf('SELECT DISTINCT("%s") FROM "%s"', col, self$table)
}
} else {
tmp_tbl = write_temp_table(private$.data, rows)
on.exit(DBI::dbRemoveTable(private$.data, tmp_tbl, temporary = TRUE))

get_query = function(col) {
sprintf('SELECT DISTINCT("%1$s"."%2$s") FROM "%3$s" LEFT JOIN "%1$s" ON "%3$s"."row_id" = "%1$s"."%4$s"',
self$table, col, tmp_tbl, self$primary_key)
}

on.exit(DBI::dbRemoveTable(private$.data, tmp_tbl, temporary = TRUE))
}

res = lapply(cols, function(col) {
query = get_query(col)
if (na_rm) {
query = sprintf('%s WHERE "%s"."%s" IS NOT NULL', query, self$table, col)
}
levels = DBI::dbGetQuery(private$.data, query)[[1L]]
levels = DBI::dbGetQuery(private$.data, paste(query, order))[[1L]]
if (is.factor(levels)) as.character(levels) else levels
})

Expand Down
4 changes: 2 additions & 2 deletions man/DataBackendDplyr.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.