nealrichardson commented on a change in pull request #11552:
URL: https://github.com/apache/arrow/pull/11552#discussion_r737012380



##########
File path: r/tests/testthat/test-dataset-write.R
##########
@@ -139,6 +139,40 @@ test_that("Writing a dataset: Parquet->Parquet (default)", 
{
   )
 })
 
+test_that("Writing a dataset: existing data behavior", {
+  ds <- open_dataset(csv_dir, partitioning = "part", format = "csv")
+  dst_dir <- make_temp_dir()
+  write_dataset(ds, dst_dir, format = "feather", partitioning = "int")
+  expect_true(dir.exists(dst_dir))
+
+  check_dataset <- function() {
+    new_ds <- open_dataset(dst_dir, format = "feather")
+
+    expect_equal(
+      new_ds %>%
+        select(string = chr, integer = int) %>%
+        filter(integer > 6 & integer < 11) %>%
+        collect() %>%
+        summarize(mean = mean(integer)),
+      df1 %>%
+        select(string = chr, integer = int) %>%
+        filter(integer > 6) %>%
+        summarize(mean = mean(integer))
+    )
+  }
+
+  check_dataset()
+  # By default we should overwrite
+  write_dataset(ds, dst_dir, format = "feather", partitioning = "int")
+  check_dataset()
+  write_dataset(ds, dst_dir, format = "feather", partitioning = "int", 
existing_data_behavior = "overwrite")
+  check_dataset()
+  expect_error(write_dataset(ds, dst_dir, format = "feather", partitioning = 
"int", existing_data_behavior = "error"), "directory is not empty")

Review comment:
       ```suggestion
     expect_error(
       write_dataset(ds, dst_dir, format = "feather", partitioning = "int", 
existing_data_behavior = "error"), 
       "directory is not empty"
     )
   ```




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