nealrichardson commented on a change in pull request #11971:
URL: https://github.com/apache/arrow/pull/11971#discussion_r812428126
##########
File path: r/tests/testthat/test-csv.R
##########
@@ -389,7 +389,7 @@ test_that("Write a CSV file with invalid input type", {
bad_input <- Array$create(1:5)
expect_error(
write_csv_arrow(bad_input, csv_file),
- regexp = "x must be an object of class 'data.frame', 'RecordBatch', or
'Table', not 'Array'."
+ regexp = "x must be an object of class 'data.frame', 'RecordBatch',
'Dataset', 'Table', or 'RecordBatchReader' not 'Array'."
Review comment:
```suggestion
regexp = "x must be an object of class .* not 'Array'."
```
##########
File path: r/tests/testthat/test-csv.R
##########
@@ -541,3 +541,21 @@ test_that("write_csv_arrow can write from
arrow_dplyr_query objects", {
expect_named(tbl_in, c("dbl", "lgl", "false", "chr"))
expect_equal(nrow(tbl_in), 3)
})
+
+test_that("write_csv_arrow can write from RecordBatchReader objects", {
+ skip_if_not_available("dataset")
+ library(dplyr, warn.conflicts = FALSE)
+
+ query_obj <- arrow_table(tbl_no_dates) %>%
+ filter(lgl == TRUE)
+
+ rb_reader <- Scanner$create(query_obj)$ToRecordBatchReader()
+
+ csv_file <- tempfile()
+ tbl_out <- write_csv_arrow(rb_reader, csv_file)
Review comment:
Pass in the query object to test that code path (it will get turned into
an RBR in the function). Also be sure to clean up the tempfile.
```suggestion
csv_file <- tempfile()
on.exit(unlink(csv_file)
tbl_out <- write_csv_arrow(query_obj, csv_file)
```
--
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]