Skip to content

Commit

Permalink
check length of statistics
Browse files Browse the repository at this point in the history
  • Loading branch information
etiennebacher committed Jul 1, 2024
1 parent f74f3c3 commit 403443b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
3 changes: 3 additions & 0 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -681,6 +681,9 @@ is_named = function(x) {

# Used in parquet write/sink
translate_statistics = function(statistics) {
if (length(statistics) != 1) {
return(Err_plain("`statistics` must be of length 1."))
}
if (is.logical(statistics)) {
if (isTRUE(statistics)) {
statistics = list(
Expand Down
4 changes: 4 additions & 0 deletions tests/testthat/test-parquet.R
Original file line number Diff line number Diff line change
Expand Up @@ -115,4 +115,8 @@ test_that("write_parquet: argument 'statistics'", {
dat$write_parquet(tmpf, statistics = "foo"),
"`statistics` must be TRUE/FALSE, 'full', or a named list."
)
expect_grepl_error(
dat$write_parquet(tmpf, statistics = c(max = TRUE, min = FALSE)),
"`statistics` must be of length 1."
)
})
4 changes: 4 additions & 0 deletions tests/testthat/test-sink_stream.R
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ test_that("sink_parquet: argument 'statistics'", {
lf$sink_parquet(tmpf, statistics = "foo"),
"`statistics` must be TRUE/FALSE, 'full', or a named list."
)
expect_grepl_error(
lf$sink_parquet(tmpf, statistics = c(max = TRUE, min = FALSE)),
"`statistics` must be of length 1."
)
})

test_that("Test sinking data to IPC file", {
Expand Down

0 comments on commit 403443b

Please sign in to comment.