diff --git a/DESCRIPTION b/DESCRIPTION index bbcb134505..ab3bd115a0 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: tiledb Type: Package -Version: 0.31.0 +Version: 0.31.0.1 Title: Modern Database Engine for Complex Data Based on Multi-Dimensional Arrays Authors@R: c( person("TileDB, Inc.", role = c("aut", "cph")), @@ -23,7 +23,7 @@ SystemRequirements: A C++17 compiler is required; on macOS compilation version 1 build selected); on x86_64 and M1 platforms pre-built TileDB Embedded libraries are available at GitHub and are used if no TileDB installation is detected, and no other option to build or download was specified by the user. -Imports: +Imports: methods, Rcpp (>= 1.0.8), nanotime, diff --git a/NEWS.md b/NEWS.md index 0c286fa38a..ffb45f11b2 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,7 @@ +# Unreleased + +* Allow `parse_query_condition()` to work on dimensions when an array is passed + # tiledb 0.31.0 * Update docs with correct S4 methods diff --git a/R/QueryCondition.R b/R/QueryCondition.R index 31c3e3d604..2f89d5e3fd 100644 --- a/R/QueryCondition.R +++ b/R/QueryCondition.R @@ -163,10 +163,6 @@ parse_query_condition <- function(expr, ta = NULL, debug = FALSE, strict = TRUE, .errorFunction("No attribute '", attr, "' present.", call. = FALSE) return(NULL) } - if (ta@sil$status[ind] != 2) { - .errorFunction("Argument '", attr, "' is not an attribute.", call. = FALSE) - return(NULL) - } ind } .getType <- function(x, tp, use_int64 = FALSE) { @@ -259,10 +255,6 @@ parse_query_condition <- function(expr, ta = NULL, debug = FALSE, strict = TRUE, .errorFunction("No attribute '", attr, "' present.", call. = FALSE) return(NULL) } - if (ta@sil$status[ind] != 2) { - .errorFunction("Argument '", attr, "' is not an attribute.", call. = FALSE) - return(NULL) - } dtype <- ta@sil$types[ind] is_enum <- ta@sil$enum[ind] } diff --git a/inst/tinytest/test_querycondition.R b/inst/tinytest/test_querycondition.R index 39442a5987..c1d2f38eb9 100644 --- a/inst/tinytest/test_querycondition.R +++ b/inst/tinytest/test_querycondition.R @@ -11,8 +11,7 @@ if (Sys.getenv("CI") != "") set_allocation_size_preference(1024*1024*5) ctx <- tiledb_ctx(limitTileDBCores()) ## simple data.frame to test against -D <- data.frame(a=1:20, - b=seq(101,120)+0.5) +D <- data.frame(a = 1:20, b = seq(101, 120) + 0.5) uri <- tempfile() fromDataFrame(D, uri, sparse=TRUE) arr <- tiledb_array(uri) @@ -201,7 +200,28 @@ if (tiledb_version(TRUE) >= "2.17.0") { expect_true(all(res$body_mass_g > 3500)) } -unlink(uri, recursive=TRUE) +unlink(uri, recursive = TRUE) + +# Check that query conditions works on dimensions +uri <- tempfile() +fromDataFrame(infert, uri, col_index = "education", sparse = TRUE) +arr <- tiledb_array(uri) +qc <- parse_query_condition(education == "0-5yrs", ta = arr) +res <- tiledb_array(uri, query_condition = qc, return_as = "data.frame")[] +expect_equal(nrow(res), sum(infert$education == "0-5yrs")) +expect_identical(unique(res$education), "0-5yrs") + +if (tiledb_version(TRUE) >= "2.17.0") { + qc2 <- parse_query_condition( + education %in% c("0-5yrs", "12+ yrs"), + ta = arr + ) + res <- tiledb_array(uri, query_condition = qc2, return_as = "data.frame")[] + expect_equal(nrow(res), sum(infert$education %in% c("0-5yrs", "12+ yrs"))) + expect_true(all(res$education %in% c("0-5yrs", "12+ yrs"))) +} + +unlink(uri, recursive = TRUE) ## (some) r-universe builds are/were breaking here if (Sys.getenv("MY_UNIVERSE", "") != "") exit_file("Skip remainder at r-universe")