thisisnic commented on a change in pull request #11971:
URL: https://github.com/apache/arrow/pull/11971#discussion_r813205610



##########
File path: r/tests/testthat/test-csv.R
##########
@@ -503,3 +510,51 @@ test_that("read_csv_arrow() deals with BOMs 
(byte-order-marks) correctly", {
     tibble(a = 1, b = 2)
   )
 })
+
+test_that("write_csv_arrow can write from Dataset objects", {
+  skip_if_not_available("dataset")
+  data_dir <- make_temp_dir()
+  write_dataset(tbl_no_dates, data_dir, partitioning = "lgl")
+  data_in <- open_dataset(data_dir)
+
+  csv_file <- tempfile()
+  tbl_out <- write_csv_arrow(data_in, csv_file)
+  expect_true(file.exists(csv_file))
+
+  tbl_in <- read_csv_arrow(csv_file)
+  expect_named(tbl_in, c("dbl", "false", "chr", "lgl"))
+  expect_equal(nrow(tbl_in), 10)
+})
+
+test_that("write_csv_arrow can write from arrow_dplyr_query objects", {
+  skip_if_not_available("dataset")
+  library(dplyr, warn.conflicts = FALSE)
+
+  query_obj <- arrow_table(tbl_no_dates) %>%
+    filter(lgl == TRUE)
+
+  csv_file <- tempfile()
+  tbl_out <- write_csv_arrow(query_obj, csv_file)
+  expect_true(file.exists(csv_file))
+
+  tbl_in <- read_csv_arrow(csv_file)
+  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)
+
+  csv_file <- tempfile()
+  on.exit(unlink(csv_file)

Review comment:
       Sure, will fix.  Is it not a bit pointless having the extra tests for 
writing from RecordBatchReader objects given it's the same as the one which 
writes from arrow_dplyr_query objects?




-- 
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]


Reply via email to