You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2021/12/02 11:36:40 UTC

[GitHub] [arrow] dragosmg commented on a change in pull request #11668: ARROW-13623 [R] write_csv_arrow update to follow the signature of readr::write_csv

dragosmg commented on a change in pull request #11668:
URL: https://github.com/apache/arrow/pull/11668#discussion_r761009126



##########
File path: r/R/csv.R
##########
@@ -623,9 +638,57 @@ readr_to_csv_convert_options <- function(na,
 #' @include arrow-package.R
 write_csv_arrow <- function(x,
                             sink,
+                            file = NULL,
                             include_header = TRUE,
-                            batch_size = 1024L) {
-  write_options <- CsvWriteOptions$create(include_header, batch_size)
+                            col_names = NULL,
+                            batch_size = 1024L,
+                            write_options = NULL,
+                            ...) {
+  unsupported_passed_args <- names(list(...))
+
+  if (length(unsupported_passed_args)) {
+    stop(
+      "The following ",
+      ngettext(length(unsupported_passed_args), "argument is ", "arguments are "),
+      "not yet supported in Arrow: ",
+      oxford_paste(unsupported_passed_args),
+      call. = FALSE
+    )
+  }
+
+  if (!missing(file) && !missing(sink)) {
+    stop(
+      "You have supplied both \"file\" and \"sink\" arguments. Please ",
+      "supply only one of them.",
+      call. = FALSE
+    )
+  }
+
+  if (missing(sink) && !missing(file)) {
+    sink <- file
+  }
+
+  if (!missing(col_names) && !missing(include_header)) {
+    stop(
+      "You have supplied both \"col_names\" and \"include_header\" ",
+      "arguments. Please supply only one of them.",
+      call. = FALSE
+    )
+  }
+
+  # default value are considered missing by base R
+  if (missing(include_header) && !missing(col_names)) {
+    message(
+      "You have supplied a value for \"col_names\". This will overwrite ",
+      "the value for the \"include_headers\" argument.")
+    include_header <- col_names
+  }

Review comment:
       I'm trying to figure what would be the best way to deal with this. `include_header` is `TRUE` by default. The main use case for the message was to warn when the user tries to pass a different / contradictory value for `col_names` which overwrites the default value for `include_header`. I could just make the message appear then `col_names == FALSE`.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org