Skip to content

Commit

Permalink
Adjust tests for enumerations
Browse files Browse the repository at this point in the history
  • Loading branch information
eddelbuettel committed Aug 14, 2023
1 parent 1c913c4 commit 8020f59
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 11 deletions.
10 changes: 6 additions & 4 deletions R/DataFrame.R
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,12 @@ fromDataFrame <- function(obj, uri, col_index=NULL, sparse=TRUE, allows_dups=spa

## turn factor columns in char columns
## TODO: add an option
#factcols <- grep("factor", sapply(obj, class))
#if (length(factcols) > 0) {
# for (i in factcols) obj[,i] <- as.character(obj[,i])
#}
if (tiledb_version(TRUE) < "2.17.0") {
factcols <- grep("factor", sapply(obj, class))
if (length(factcols) > 0) {
for (i in factcols) obj[,i] <- as.character(obj[,i])
}
}

## Create default filter_list from filter vector, 'NONE' and 'ZSTD' is default
default_filter_list <- tiledb_filter_list(sapply(filter, tiledb_filter))
Expand Down
6 changes: 3 additions & 3 deletions R/QueryCondition.R
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ tiledb_query_condition <- function(ctx = tiledb_get_context()) {
#' @return The initialized 'tiledb_query_condition' object
#' @export
tiledb_query_condition_init <- function(attr, value, dtype, op, qc = tiledb_query_condition()) {
stopifnot("Argument 'qc' with query condition object required" = is(qc, "tiledb_query_condition"),
stopifnot("Argument 'qc' with query condition object required" = inherits(qc, "tiledb_query_condition"),
"Argument 'attr' must be character" = is.character(attr),
"Argument 'value' must be of length one" = (is.vector(value) ||
bit64::is.integer64(value) ||
Expand Down Expand Up @@ -164,8 +164,8 @@ parse_query_condition <- function(expr, ta=NULL, debug=FALSE, strict=TRUE, use_i
if (debug) cat("-- [", as.character(x[2]), "]",
" ", as.character(x[1]),
" [", as.character(x[3]), "]\n", sep="")
.makeExpr(x[[2]])
.makeExpr(x[[3]])
.makeExpr(x[[2]], debug=debug)
.makeExpr(x[[3]], debug=debug)
tiledb_query_condition_combine(.makeExpr(x[[2]]),
.makeExpr(x[[3]]),
.mapBoolToCharacter(as.character(x[1])))
Expand Down
6 changes: 3 additions & 3 deletions inst/tinytest/test_query.R
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ expect_equal(nv[3], n) # third is length of validity buffer (if

#})

## n=31
## check for warning in insufficient memory
oldcfg <- tiledb_config()
cfg <- tiledb_config()
Expand All @@ -250,23 +251,22 @@ expect_true(nchar(res) > 1000) # safe lower boundary

ctx <- tiledb_ctx(oldcfg) # reset config


## n==35
## check deletes
if (tiledb_version(TRUE) < "2.12.0") exit_file("TileDB deletes requires TileDB 2.12.* or greater")
if (!requireNamespace("palmerpenguins", quietly=TRUE)) exit_file("remainder needs 'palmerpenguins'")
uri <- tempfile()
pp <- palmerpenguins::penguins
fromDataFrame(pp, uri, sparse = TRUE, col_index = c("species", "year"))

qc <- parse_query_condition(body_mass_g > 4000 || island == "Biscoe" || sex == "male")
arr <- tiledb_array(uri)
qc <- parse_query_condition(body_mass_g > 4000 || island == "Biscoe" || sex == "male", ta = arr)
qry <- tiledb_query(arr, "DELETE")
qry <- tiledb_query_set_condition(qry, qc)
tiledb_query_submit(qry)
tiledb_query_finalize(qry)

oo <- tiledb_array(uri, return_as="data.frame", strings_as_factors=TRUE)[]

expect_equal(nrow(oo), 84) # instead of 344 pre-deletion


Expand Down
2 changes: 1 addition & 1 deletion inst/tinytest/test_tiledbarray.R
Original file line number Diff line number Diff line change
Expand Up @@ -988,7 +988,7 @@ expect_equal(tiledb_array_get_non_empty_domain_from_name(arr, "d2"), c("a", "c")
## access schema from uri
schema2 <- tiledb::schema(tmp)
expect_true(is(schema2, "tiledb_array_schema"))
expect_equal(schema, schema2)
expect_equal(schema@ptr, schema2@ptr) # schema2 has two slots as we now return array pointer too

## access schema from array
schema3 <- tiledb::schema(arr)
Expand Down

0 comments on commit 8020f59

Please sign in to comment.