nealrichardson commented on code in PR #13690:
URL: https://github.com/apache/arrow/pull/13690#discussion_r930110815
##########
r/tests/testthat/test-dataset-write.R:
##########
@@ -139,6 +139,23 @@ test_that("Writing a dataset: Parquet->Parquet (default)",
{
)
})
+test_that("Writing a dataset: `basename_template` default behavier", {
Review Comment:
We should have a test of providing `basename_template`, looks like we don't
have one. Would you be interested in adding one here?
##########
r/R/dataset-write.R:
##########
@@ -123,7 +124,7 @@ write_dataset <- function(dataset,
path,
format = c("parquet", "feather", "arrow", "ipc",
"csv"),
partitioning = dplyr::group_vars(dataset),
- basename_template = paste0("part-{i}.",
as.character(format)),
+ basename_template = NULL,
Review Comment:
I actually don't think you need this change due to the magic of lazy
evaluation, you just need to add `format <- ifelse(as.character(format) %in%
c("feather", "ipc"), "arrow", format)` after `format <- match.arg(format)`
```
> f <- function(x = c("a", "b", "c"), basename_template =
paste0("part-{i}.", x)) {
+ x <- match.arg(x)
+ x <- toupper(x)
+ basename_template
+ }
> f()
[1] "part-{i}.A"
```
The benefit of this is that you still get to see the default value for
`basename_template` in the signature/docs.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]