Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow parse_query_condition() to work on dimensions #796

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: 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")),
Expand All @@ -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,
Expand Down
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
8 changes: 0 additions & 8 deletions R/QueryCondition.R
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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]
}
Expand Down
26 changes: 23 additions & 3 deletions inst/tinytest/test_querycondition.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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")
Expand Down