Skip to content

Commit

Permalink
Fix/duckdb missings (#34)
Browse files Browse the repository at this point in the history
  • Loading branch information
sebffischer committed Oct 17, 2023
1 parent 0fc64eb commit 3ba5812
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
@@ -1,6 +1,6 @@
Package: mlr3db
Title: Data Base Backend for 'mlr3'
Version: 0.5.1
Version: 0.5.1-9000
Authors@R:
person(given = "Michel",
family = "Lang",
Expand Down
4 changes: 4 additions & 0 deletions NEWS.md
@@ -1,3 +1,7 @@
# mlr3db 0.5.2

- Bugfix: `DataBackendDuckDB` calculated missing values incorrectly

# mlr3db 0.5.1

- Compatibility with new duckdb version (#36).
Expand Down
2 changes: 1 addition & 1 deletion R/DataBackendDuckDB.R
Expand Up @@ -188,7 +188,7 @@ DataBackendDuckDB = R6Class("DataBackendDuckDB", inherit = DataBackend, cloneabl
)

counts = unlist(DBI::dbGetQuery(private$.data, query), recursive = FALSE)
setNames(as.integer(self$nrow - counts), cols)
setNames(as.integer(length(rows) - counts), cols)
}
),

Expand Down
7 changes: 7 additions & 0 deletions tests/testthat/test_duckdb.R
Expand Up @@ -62,3 +62,10 @@ test_that("multiple parquet file", {
b = as_duckdb_backend(files)
expect_backend(b)
})

test_that("missings are calculated correctly", {
d = data.frame(x = c(NA, 1), y = c(1, 1))
b = as_duckdb_backend(d, path = tempfile())
expect_equal(b$missings(1, "x"), c(x = 1))
expect_equal(b$missings(2, "x"), c(x = 0))
})

0 comments on commit 3ba5812

Please sign in to comment.