From e85f12de2296fd65b9817bf5ad23838bdb7277a1 Mon Sep 17 00:00:00 2001 From: chainsawriot Date: Tue, 19 Sep 2023 11:56:27 +0200 Subject: [PATCH] Fix #376 (#377) * Fix #376 Did I forget anything? * Update NEWS further [no ci] --- DESCRIPTION | 6 +++--- NEWS.md | 4 ++++ R/import.R | 5 ++++- R/import_methods.R | 2 ++ R/set_class.R | 2 ++ R/sysdata.rda | Bin 2231 -> 2225 bytes README.md | 4 ++-- data-raw/single.json | 4 ++-- man/import.Rd | 2 +- man/import_list.Rd | 2 +- tests/testthat/test_format_feather.R | 3 +++ tests/testthat/test_format_parquet.R | 1 + tests/testthat/test_identical.R | 1 + tests/testthat/test_import_list.R | 2 ++ tests/testthat/test_set_class.R | 12 ++++++++++++ 15 files changed, 40 insertions(+), 10 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index b08cceb2..8f3070dc 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: rio Type: Package Title: A Swiss-Army Knife for Data I/O -Version: 1.0.0 +Version: 1.0.1 Authors@R: c(person("Jason", "Becker", role = "aut", email = "jason@jbecker.co"), person("Chung-hong", "Chan", role = c("aut", "cre"), email = "chainsawtiney@gmail.com", comment = c(ORCID = "0000-0002-6232-7530")), @@ -49,7 +49,6 @@ Imports: curl (>= 0.6), data.table (>= 1.11.2), readxl (>= 0.1.1), - arrow (>= 0.17.0), tibble, stringi, writexl, @@ -72,7 +71,8 @@ Suggests: rmatio, xml2 (>= 1.2.0), yaml, - qs + qs, + arrow (>= 0.17.0) License: GPL-2 VignetteBuilder: knitr Encoding: UTF-8 diff --git a/NEWS.md b/NEWS.md index 495ab429..7e3979d1 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,7 @@ +# rio 1.0.1 + +* POTENTIALLY BREAKING: Due to compiling time concerns, roll back the decision to move `arrow` to `Imports`. It is now `Suggests`. `setclass = "arrow"` works if `arrow` is installed. #315 #376 + # rio 1.0.0 * Stop loading the entire namespace of a suggested package when it is available #296 diff --git a/R/import.R b/R/import.R index 61cd644f..d8cb780c 100644 --- a/R/import.R +++ b/R/import.R @@ -6,7 +6,7 @@ #' @param setclass An optional character vector specifying one or more classes #' to set on the import. By default, the return object is always a #' \dQuote{data.frame}. Allowed values include \dQuote{tbl_df}, \dQuote{tbl}, or -#' \dQuote{tibble} (if using tibble), \dQuote{arrow}, \dQuote{arrow_table} (if using arrow table) or \dQuote{data.table} (if using +#' \dQuote{tibble} (if using tibble), \dQuote{arrow}, \dQuote{arrow_table} (if using arrow table; the suggested package `arrow` must be installed) or \dQuote{data.table} (if using #' data.table). Other values are ignored, such that a data.frame is returned. #' The parameter takes precedents over parameters in \dots which set a different class. #' @param which This argument is used to control import from multi-object files; as a rule `import` only ever returns a single data frame (use [import_list()] to import multiple data frames from a multi-object file). If `file` is a compressed directory, `which` can be either a character string specifying a filename or an integer specifying which file (in locale sort order) to extract from the compressed directory. For Excel spreadsheets, this can be used to specify a sheet name or number. For .Rdata files, this can be an object name. For HTML files, it identifies which table to extract (from document order). Ignored otherwise. A character string value will be used as a regular expression, such that the extracted file is the first match of the regular expression against the file names in the archive. @@ -102,6 +102,9 @@ #' @seealso [import_list()], [characterize()], [gather_attrs()], [export()], [convert()] #' @export import <- function(file, format, setclass = getOption("rio.import.class", "data.frame"), which, ...) { + if (setclass %in% c("arrow", "arrow_table")) { + .check_pkg_availability("arrow") + } .check_file(file, single_only = TRUE) if (R.utils::isUrl(file)) { file <- remote_to_local(file, format = format) diff --git a/R/import_methods.R b/R/import_methods.R index ea390388..4331ff0e 100644 --- a/R/import_methods.R +++ b/R/import_methods.R @@ -152,6 +152,7 @@ import_delim <- function(file, which = 1, sep = "auto", header = "auto", strings #' @export .import.rio_feather <- function(file, which = 1, ...) { + .check_pkg_availability("arrow") .docall(arrow::read_feather, ..., args = list(file = file)) } @@ -386,6 +387,7 @@ extract_html_row <- function(x, empty_value) { #' @export .import.rio_parquet <- function(file, which = 1, ...) { + .check_pkg_availability("arrow") .docall(arrow::read_parquet, ..., args = list(file = file, as_data_frame = TRUE)) } diff --git a/R/set_class.R b/R/set_class.R index 0eaaf0b3..2f64ce52 100644 --- a/R/set_class.R +++ b/R/set_class.R @@ -12,6 +12,8 @@ set_class <- function(x, class = NULL) { } if (any(c("arrow", "arrow_table") %in% class)) { + ## because setclass can be used without import, must check again + .check_pkg_availability("arrow") return(.ensure_arrow(x)) } return(.ensure_data_frame(x)) diff --git a/R/sysdata.rda b/R/sysdata.rda index d150011aa89144db8f877511d8ab34aaec054129..4cd65044300f0bddcc13f45b87fe4861f4421aca 100644 GIT binary patch delta 2222 zcmV;f2vPU95wQ^tLRx4!F+o`-Q(28Tk?4^Q9e+KshSr=6$+o8284R_m2!O&#Aq72z zn5UCWA?YYk7Q)XI8fX*5MVX+24x00E!?001-qXfT1s zhD|idpaFsa&}7g6GH3t*88QK&lTk#}(LYmE@ifS4cofj`nrO-D0LTZZ27mwn9B5?I zOn;gH7$6M>O#lNXfB*rLAQ}l2L7_4<&?YJ58lI&;O+8fhqJERqPb40vs1MZ`A)`-G zjWU%90{6_Xb0GqlSfD^Lv;rj3KpClkfM0e=Ah{~Y~Y^Z-dwOOyQ|2`E_rh(<{W z0|tR2s_c~nU*C#)zVCPa`+oW(FU#Li>VK;0zuS=V55;oKIg^P3zhqx%w!lGyjDsP6 zsc2ib6EJIq`AVWHRcuI6reR>V0cY1a`{O}RHWu5U>hL*fozmPrBU0gja~bM&7#YXG zq@>!?;90Czf&idJ6&XndK3XJ(nk8u+%1c_eWN!^oZ(@YSerXzYVA%tvXSi7R?C~aKmn-;Fay>uz&V=!Rj zInmuHreznL+!!~k9j17*#fEEdlo+9Oq!J?BY^750v=Aqml~swSRh-lrR1i?M9?tUR zTO*1Jn-#d@FAJ@EviWC20!VjY5PyJ#gq-LElne{1kRjP3kQ9Q17A%ZlED;nHM1Vk8 zvH-A9B9KrZq!fb4BNQTwBrSx13JoIW9V|&8p`?-RkzTKcD{q4K#*&Z2DK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