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 1 commit
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
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
Loading