skip_if_no_db()
# Shared connection object
conn = get_scidb_connection()
schemaTemplate = conn$array_from_schema(
"<lower:string COMPRESSION 'zlib', upper:string, f_int32:int32, f_int64:int64, f_bool: bool, f_double: double>
[da=0:*:0:*; db=0:*:0:*]"
)
ArrayContent = data.frame(
da=0:4, db=10:14,
lower = letters[1:5],
upper = LETTERS[1:5],
f_int32 = -5:-1,
f_int64 = 1:5 * 10.0,
f_bool = c(T,NA,F,NA,F),
f_double = c(3.14, 2.0, NA, 0, -99),
stringsAsFactors = FALSE
)
RefArray = conn$
array_from_df(ArrayContent, schemaTemplate, force_template_schema = T)$
persist(.gc = FALSE)
assert_df_match = function(actual_df, expected_df) {
expect_equal(
actual_df %>% dplyr::arrange(!!! sapply(names(actual_df), as.name)),
expected_df
)
}
test_that("Arrow Output Returns Correct Results for to_df", {
arrow_df <- RefArray$to_df(arrow = TRUE)
assert_df_match(arrow_df, ArrayContent %>% dplyr::select(-da, -db))
})
test_that("Arrow Output Returns Correct Results for to_df_all", {
arrow_df <- RefArray$to_df_all(arrow = TRUE)
assert_df_match(arrow_df, ArrayContent)
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.