From 0e53d20383e1fb1614e3cd0060a5ae07c5871271 Mon Sep 17 00:00:00 2001 From: Dirk Eddelbuettel Date: Mon, 6 Nov 2023 14:55:53 -0600 Subject: [PATCH] Add test for non-int32 columns and parsing query conditions --- inst/tinytest/test_arrayschemaevolution.R | 35 +++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/inst/tinytest/test_arrayschemaevolution.R b/inst/tinytest/test_arrayschemaevolution.R index 994f399222..ca9ed5332e 100644 --- a/inst/tinytest/test_arrayschemaevolution.R +++ b/inst/tinytest/test_arrayschemaevolution.R @@ -107,3 +107,38 @@ ase <- tiledb_array_schema_evolution_extend_enumeration(ase, arr, "an_enum", c(" tiledb_array_schema_evolution_array_evolve(ase, uri) arr <- tiledb_array(uri, return_as="data.frame")[] expect_equal(levels(arr[, "b"]), c("red", "green", "blue", "orange")) + + +## -- testing query condition on non int32 columns +run_int_col_test <- function(coltype) { + uri <- tempfile() + enums <- c("blue", "green", "red") + dom <- tiledb_domain(dims = tiledb_dim(name="dim", domain=c(0L,100L), tile=10L, type="INT32")) + attrs <- c(tiledb_attr(name="fct", type = coltype, enumeration=enums), + tiledb_attr(name="dbl", type = "FLOAT64")) + schema <- tiledb_array_schema(domain=dom, attrs=attrs, sparse=TRUE, enumerations=list(fct=enums)) + tiledb_array_create(uri, schema) + + set.seed(42) + df <- data.frame(dim = 1:10, fct = sample(1:length(enums), 10, replace=TRUE) - 1, dbl = rnorm(10)) + arr <- tiledb_array(uri) + arr[] <- df + + qc <- + res <- tiledb_array(uri, return_as="data.table", query_condition = parse_query_condition(fct == blue, arr))[] + expect_equal(nrow(res), 5) + + res <- tiledb_array(uri, return_as="data.table", query_condition = parse_query_condition(fct == green, arr))[] + expect_equal(nrow(res), 3) + + res <- tiledb_array(uri, return_as="data.table", query_condition = parse_query_condition(fct == red, arr))[] + expect_equal(nrow(res), 2) + + res <- tiledb_array(uri, return_as="data.table", query_condition = parse_query_condition(fct != blue, arr))[] + expect_equal(nrow(res), 5) + + expect_error(tiledb_array(uri, return_as="data.table", query_condition = parse_query_condition(fct > blue, arr))[]) + + unlink(uri) +} +sapply(c("INT8", "INT16", "INT32", "UINT8", "UINT16", "UINT32"), run_int_col_test)