jonkeane commented on a change in pull request #12170:
URL: https://github.com/apache/arrow/pull/12170#discussion_r786992365
##########
File path: r/tests/testthat/test-dataset-write.R
##########
@@ -505,3 +505,40 @@ test_that("Max partitions fails with non-integer values
and less than required p
"max_partitions must be a positive, non-missing integer"
)
})
+
+test_that("write_dataset checks for format-specific arguments", {
+ df <- tibble::tibble(
+ int = 1:10,
+ dbl = as.numeric(1:10),
+ lgl = rep(c(TRUE, FALSE, NA, TRUE, FALSE), 2),
+ chr = letters[1:10],
+ )
+ dst_dir <- make_temp_dir()
+ expect_error(
+ write_dataset(df, dst_dir, format = "feather", compression = "snappy"),
+ "The following argument is not valid for your chosen 'format':
\"compression\""
+ )
+ expect_error(
+ write_dataset(df, dst_dir, format = "feather", nonsensical_arg =
"blah-blah"),
+ "The following argument is not valid for your chosen 'format':
\"nonsensical_arg\""
+ )
+
+ expect_error(
+ write_dataset(df, dst_dir, format = "arrow", nonsensical_arg =
"blah-blah"),
+ "The following argument is not valid for your chosen 'format':
\"nonsensical_arg\""
+ )
+ expect_error(
+ write_dataset(df, dst_dir, format = "ipc", nonsensical_arg = "blah-blah"),
+ "The following argument is not valid for your chosen 'format':
\"nonsensical_arg\""
+ )
+
+ expect_error(
+ write_dataset(df, dst_dir, format = "csv", nonsensical_arg = "blah-blah"),
+ "nonsensical_arg = \"blah-blah\""
+ )
+
+ expect_error(
+ write_dataset(df, dst_dir, format = "parquet", nonsensical_arg =
"blah-blah"),
+ "The following argument is not valid for your chosen 'format':
\"non_sensical_arg\""
+ )
Review comment:
_nods_ I think we should too (and possibly also csv, if that has the
same issue). It might be a bit of scope creep (though not too much).
Doing it for those might also alter where/how we do this (or it might not! I
haven't tried it myself).
--
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]