@@ -254,8 +254,6 @@ test_that("Row-level metadata (does not) roundtrip in datasets", {
254254 skip_if_not_available(" dataset" )
255255 skip_if_not_available(" parquet" )
256256
257- library(dplyr , warn.conflicts = FALSE )
258-
259257 df <- tibble :: tibble(
260258 metadata = list (
261259 structure(1 , my_value_as_attr = 1 ),
@@ -269,39 +267,36 @@ test_that("Row-level metadata (does not) roundtrip in datasets", {
269267
270268 dst_dir <- make_temp_dir()
271269
272- withr :: with_options(
273- list (" arrow.preserve_row_level_metadata" = TRUE ),
274- {
275- expect_warning(
276- write_dataset(df , dst_dir , partitioning = " part" ),
277- " Row-level metadata is not compatible with datasets and will be discarded"
278- )
279-
280- # Reset directory as previous write will have created some files and the default
281- # behavior is to error on existing
282- dst_dir <- make_temp_dir()
283- # but we need to write a dataset with row-level metadata to make sure when
284- # reading ones that have been written with them we warn appropriately
285- fake_func_name <- write_dataset
286- fake_func_name(df , dst_dir , partitioning = " part" )
287-
288- ds <- open_dataset(dst_dir )
289- expect_warning(
290- df_from_ds <- collect(ds ),
291- " Row-level metadata is not compatible with this operation and has been ignored"
292- )
293- expect_equal(
294- arrange(df_from_ds , int ),
295- arrange(df , int ),
296- ignore_attr = TRUE
297- )
298-
299- # however there is *no* warning if we don't select the metadata column
300- expect_warning(
301- df_from_ds <- ds %> % select(int ) %> % collect(),
302- NA
303- )
304- }
270+ withr :: local_options(" arrow.preserve_row_level_metadata" = TRUE )
271+
272+ expect_warning(
273+ write_dataset(df , dst_dir , partitioning = " part" ),
274+ " Row-level metadata is not compatible with datasets and will be discarded"
275+ )
276+
277+ # Reset directory as previous write will have created some files and the default
278+ # behavior is to error on existing
279+ dst_dir <- make_temp_dir()
280+ # but we need to write a dataset with row-level metadata to make sure when
281+ # reading ones that have been written with them we warn appropriately
282+ fake_func_name <- write_dataset
283+ fake_func_name(df , dst_dir , partitioning = " part" )
284+
285+ ds <- open_dataset(dst_dir )
286+ expect_warning(
287+ df_from_ds <- collect(ds ),
288+ " Row-level metadata is not compatible with this operation and has been ignored"
289+ )
290+ expect_equal(
291+ dplyr :: arrange(df_from_ds , int ),
292+ dplyr :: arrange(df , int ),
293+ ignore_attr = TRUE
294+ )
295+
296+ # however there is *no* warning if we don't select the metadata column
297+ expect_warning(
298+ df_from_ds <- ds %> % dplyr :: select(int ) %> % dplyr :: collect(),
299+ NA
305300 )
306301})
307302
0 commit comments