diff --git a/r/NAMESPACE b/r/NAMESPACE index 0e3f65ca9d7e1..ada3af1571b82 100644 --- a/r/NAMESPACE +++ b/r/NAMESPACE @@ -174,6 +174,7 @@ importFrom(rlang,dots_n) importFrom(rlang,enquo) importFrom(rlang,enquos) importFrom(rlang,is_false) +importFrom(rlang,is_integerish) importFrom(rlang,list2) importFrom(rlang,quo_is_null) importFrom(rlang,warn) diff --git a/r/R/arrow-package.R b/r/R/arrow-package.R index 7ce881f90b08c..845f2c708f98c 100644 --- a/r/R/arrow-package.R +++ b/r/R/arrow-package.R @@ -18,7 +18,7 @@ #' @importFrom R6 R6Class #' @importFrom purrr map map_int map2 #' @importFrom assertthat assert_that -#' @importFrom rlang list2 %||% is_false abort dots_n warn enquo quo_is_null enquos +#' @importFrom rlang list2 %||% is_false abort dots_n warn enquo quo_is_null enquos is_integerish #' @importFrom Rcpp sourceCpp #' @importFrom tidyselect vars_select #' @useDynLib arrow, .registration = TRUE diff --git a/r/R/parquet.R b/r/R/parquet.R index 8e19dbc9f8a47..e569061f50242 100644 --- a/r/R/parquet.R +++ b/r/R/parquet.R @@ -83,8 +83,6 @@ ParquetWriterProperties_Builder <- R6Class("ParquetWriterProperties_Builder", in set_compression = function(table, compression){ if (is.character(compression) && is.null(names(compression)) && length(compression) == 1L) { parquet___ArrowWriterProperties___Builder__default_compression(self, compression_from_name(compression)) - } else if (inherits(compression, "Codec")) { - parquet___ArrowWriterProperties___Builder__default_compression(self, compression_from_name(compression$name)) } else { column_names <- names(table) if (is.character(compression) && is.null(names(compression)) && length(compression) == length(column_names)) { @@ -98,9 +96,8 @@ ParquetWriterProperties_Builder <- R6Class("ParquetWriterProperties_Builder", in }, set_compression_level = function(table, compression_level){ - if (!rlang::is_integerish(compression_level)) { - abort("unsupported compression_level= specification") - } + assert_that(is_integerish(compression_level), msg = "unsupported compression_level= specification") + column_names <- names(table) if (is.null(given_names <- names(compression_level))) { if (length(compression_level) == 1L) { @@ -116,9 +113,7 @@ ParquetWriterProperties_Builder <- R6Class("ParquetWriterProperties_Builder", in }, set_dictionary = function(table, use_dictionary) { - if (!is.logical(use_dictionary)) { - abort("unsupported use_dictionary= specification") - } + assert_that(is.logical(use_dictionary), msg = "unsupported use_dictionary= specification") column_names <- names(table) if (is.null(given_names <- names(use_dictionary))) { @@ -135,9 +130,7 @@ ParquetWriterProperties_Builder <- R6Class("ParquetWriterProperties_Builder", in }, set_write_statistics = function(table, write_statistics) { - if (!is.logical(write_statistics)) { - abort("unsupported write_statistics= specification") - } + assert_that(is.logical(write_statistics), msg = "unsupported write_statistics= specification") column_names <- names(table) if (is.null(given_names <- names(write_statistics))) { @@ -212,14 +205,13 @@ ParquetFileWriter$create <- function( #' [Parquet](https://parquet.apache.org/) is a columnar storage file format. #' This function enables you to write Parquet files from R. #' -#' @param table An [arrow::Table][Table], or an object convertible to it with [to_arrow()] +#' @param table An [arrow::Table][Table], or an object convertible to it. #' @param sink an [arrow::io::OutputStream][OutputStream] or a string which is interpreted as a file path #' @param chunk_size chunk size. If NULL, the number of rows of the table is used #' #' @param version parquet version #' @param compression compression specification. Possible values: #' - a single string: uses that compression algorithm for all columns -#' - a single [Codec][Codec] instance: uses that compression algorithm for all columns #' - an unnamed string vector: specify a compression algorithm for each, same order as the columns #' - a named string vector: specify compression algorithm individually #' @param compression_level compression level. A single integer, a named integer vector diff --git a/r/man/write_parquet.Rd b/r/man/write_parquet.Rd index a879df3453622..9d1554f92d6d0 100644 --- a/r/man/write_parquet.Rd +++ b/r/man/write_parquet.Rd @@ -19,7 +19,7 @@ write_parquet(table, sink, chunk_size = NULL, version = NULL, allow_truncated_timestamps = allow_truncated_timestamps)) } \arguments{ -\item{table}{An \link[=Table]{arrow::Table}, or an object convertible to it with \code{\link[=to_arrow]{to_arrow()}}} +\item{table}{An \link[=Table]{arrow::Table}, or an object convertible to it.} \item{sink}{an \link[=OutputStream]{arrow::io::OutputStream} or a string which is interpreted as a file path} @@ -30,7 +30,6 @@ write_parquet(table, sink, chunk_size = NULL, version = NULL, \item{compression}{compression specification. Possible values: \itemize{ \item a single string: uses that compression algorithm for all columns -\item a single \link{Codec} instance: uses that compression algorithm for all columns \item an unnamed string vector: specify a compression algorithm for each, same order as the columns \item a named string vector: specify compression algorithm individually }} diff --git a/r/tests/testthat/test-parquet.R b/r/tests/testthat/test-parquet.R index 6c43fe6e45826..1f264e5eef14d 100644 --- a/r/tests/testthat/test-parquet.R +++ b/r/tests/testthat/test-parquet.R @@ -57,9 +57,6 @@ test_that("write_parquet() handles various compression= specs", { # a single string expect_error(write_parquet(tab, tf, compression = "snappy"), NA) - # a single Codec - expect_error(write_parquet(tab, tf, compression = Codec$create("snappy")), NA) - # one string per column expect_error(write_parquet(tab, tf, compression = rep("snappy", 3L)), NA)