jonkeane commented on code in PR #49343:
URL: https://github.com/apache/arrow/pull/49343#discussion_r2842745421


##########
r/tests/testthat/test-dataset-write.R:
##########
@@ -1015,3 +1015,20 @@ test_that("Dataset write wrappers can write flat files 
using readr::write_csv()
     c("true", "false", "NOVALUE", "true", "false", "true", "false", "NOVALUE", 
"true", "false")
   )
 })
+
+test_that("Row order is preserved when writing large parquet dataset", {
+  skip_if_not_available("parquet")
+  # Make a data frame with a sufficiently large number of rows.
+  df <- data.frame(x = 1:1.1e6)
+  dst_dir1 <- make_temp_dir()
+  write_dataset(df, dst_dir1)
+
+  dst_dir2 <- make_temp_dir()
+  write_dataset(df, dst_dir2, preserve_order = TRUE)
+
+  ds1 <- open_dataset(dst_dir1) |> collect()
+  ds2 <- open_dataset(dst_dir2) |> collect()
+
+  expect_true(any(ds1$x != df$x))
+  expect_true(all(ds2$x == df$x))

Review Comment:
   ```suggestion
     unordered_dir <- make_temp_dir()
     write_dataset(df, unordered_dir)
   
     ordered_dir <- make_temp_dir()
     write_dataset(df, ordered_dir, preserve_order = TRUE)
   
     unordered_ds <- open_dataset(unordered_dir) |> collect()
     ordered_ds2 <- open_dataset(ordered_dir) |> collect()
   
     expect_true(any(unordered_ds$x != df$x))
     expect_true(all(ordered_ds$x == df$x))
   ```
   
   Making the names slightly more understandable / readable. 
   
   also what about:
   
   ```
   # unordered is setequal, but not ordered
   expect_setequal(unordered_ds$x, df$x)
   expect_false(all(unordered_ds$x == df$x))
   
   # but ordered is exactly equal
   expect_equal(ordered_ds$x, df$x)
   ```



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