Skip to content

Commit 71a2ff5

Browse files
committed
Swap out read/write Feather for IPC
1 parent bc612c6 commit 71a2ff5

12 files changed

Lines changed: 46 additions & 38 deletions

r/tests/testthat/helper-filesystems.R

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,15 @@
2727
test_filesystem <- function(name, fs, path_formatter, uri_formatter) {
2828
# NOTE: it's important that we label these tests with name of filesystem so
2929
# that we can differentiate the different calls to these test in the output.
30-
test_that(sprintf("read/write Feather on %s using URIs", name), {
31-
write_feather(example_data, uri_formatter("test.feather"))
32-
expect_identical(read_feather(uri_formatter("test.feather")), example_data)
30+
test_that(sprintf("read/write IPC on %s using URIs", name), {
31+
write_ipc_file(example_data, uri_formatter("test.arrow"))
32+
expect_identical(read_ipc_file(uri_formatter("test.arrow")), example_data)
3333
})
3434

35-
test_that(sprintf("read/write Feather on %s using Filesystem", name), {
36-
write_feather(example_data, fs$path(path_formatter("test2.feather")))
35+
test_that(sprintf("read/write IPC on %s using Filesystem", name), {
36+
write_ipc_file(example_data, fs$path(path_formatter("test2.arrow")))
3737
expect_identical(
38-
read_feather(fs$path(path_formatter("test2.feather"))),
38+
read_ipc_file(fs$path(path_formatter("test2.arrow"))),
3939
example_data
4040
)
4141
})

r/tests/testthat/test-Array.R

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -345,10 +345,10 @@ test_that("Timezone handling in Arrow roundtrip (ARROW-3543)", {
345345
# Confirming that the columns are in fact different
346346
expect_all_false(df$no_tz == df$yes_tz)
347347
}
348-
feather_file <- tempfile()
349-
on.exit(unlink(feather_file))
350-
write_feather(df, feather_file)
351-
expect_identical(read_feather(feather_file), df)
348+
ipc_file <- tempfile()
349+
on.exit(unlink(ipc_file))
350+
write_ipc_file(df, ipc_file)
351+
expect_identical(read_ipc_file(ipc_file), df)
352352
})
353353

354354
test_that("array supports integer64", {

r/tests/testthat/test-buffer.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ test_that("can read remaining bytes of a RandomAccessFile", {
6969
tab <- Table$create(!!!tbl)
7070

7171
tf <- tempfile()
72-
all_bytes <- write_feather(tab, tf)
72+
all_bytes <- write_ipc_file(tab, tf)
7373

7474
file <- ReadableFile$create(tf)
7575
expect_equal(file$tell(), 0)

r/tests/testthat/test-dataset-write.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ test_that("Writing a dataset: CSV->IPC", {
6262
)
6363

6464
# Check whether "int" is present in the files or just in the dirs
65-
first <- read_feather(
65+
first <- read_ipc_file(
6666
dir(dst_dir, pattern = ".arrow$", recursive = TRUE, full.names = TRUE)[1],
6767
as_data_frame = FALSE
6868
)

r/tests/testthat/test-dataset.R

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ test_that("Setup (putting data in the dir)", {
4141
# Now, an IPC format dataset
4242
dir.create(file.path(ipc_dir, 3))
4343
dir.create(file.path(ipc_dir, 4))
44-
write_feather(df1, file.path(ipc_dir, 3, "file1.arrow"))
45-
write_feather(df2, file.path(ipc_dir, 4, "file2.arrow"))
44+
write_ipc_file(df1, file.path(ipc_dir, 3, "file1.arrow"))
45+
write_ipc_file(df2, file.path(ipc_dir, 4, "file2.arrow"))
4646
expect_length(dir(ipc_dir, recursive = TRUE), 2)
4747
})
4848

@@ -98,7 +98,7 @@ test_that("URI-decoding with directory partitioning", {
9898
selector <- FileSelector$create(root, recursive = TRUE)
9999
dir1 <- file.path(root, "2021-05-04 00%3A00%3A00", "%24")
100100
dir.create(dir1, recursive = TRUE)
101-
write_feather(df1, file.path(dir1, "data.feather"))
101+
write_ipc_file(df1, file.path(dir1, "data.arrow"))
102102

103103
partitioning <- DirectoryPartitioning$create(
104104
schema(date = timestamp(unit = "s"), string = utf8())
@@ -178,7 +178,7 @@ test_that("URI-decoding with hive partitioning", {
178178
selector <- FileSelector$create(root, recursive = TRUE)
179179
dir1 <- file.path(root, "date=2021-05-04 00%3A00%3A00", "string=%24")
180180
dir.create(dir1, recursive = TRUE)
181-
write_feather(df1, file.path(dir1, "data.feather"))
181+
write_ipc_file(df1, file.path(dir1, "data.arrow"))
182182

183183
partitioning <- hive_partition(
184184
date = timestamp(unit = "s"),
@@ -254,7 +254,7 @@ test_that("URI-decoding with hive partitioning with key encoded", {
254254
selector <- FileSelector$create(root, recursive = TRUE)
255255
dir1 <- file.path(root, "test%20key=2021-05-04 00%3A00%3A00", "test%20key1=%24")
256256
dir.create(dir1, recursive = TRUE)
257-
write_feather(df1, file.path(dir1, "data.feather"))
257+
write_ipc_file(df1, file.path(dir1, "data.arrow"))
258258

259259
partitioning <- hive_partition(
260260
`test key` = timestamp(unit = "s"),

r/tests/testthat/test-extension.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,8 +191,8 @@ test_that("vctrs extension type works", {
191191

192192
tf <- tempfile()
193193
on.exit(unlink(tf))
194-
write_feather(arrow_table(col = array_in), tf)
195-
table_out <- read_feather(tf, as_data_frame = FALSE)
194+
write_ipc_file(arrow_table(col = array_in), tf)
195+
table_out <- read_ipc_file(tf, as_data_frame = FALSE)
196196
array_out <- table_out$col$chunk(0)
197197

198198
expect_r6_class(array_out$type, "VctrsExtensionType")

r/tests/testthat/test-feather.R

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -324,8 +324,16 @@ test_that("Error is created when feather reads a parquet file", {
324324
)
325325
})
326326

327-
test_that("The read_ipc_file function is an alias of read_feather", {
328-
expect_identical(read_ipc_file, read_feather)
327+
test_that("read_feather calls read_ipc_file", {
328+
tf <- tempfile()
329+
on.exit(unlink(tf))
330+
write_ipc_file(example_data, tf)
331+
expect_warning(
332+
result_feather <- read_feather(tf),
333+
"deprecated"
334+
)
335+
result_ipc <- read_ipc_file(tf)
336+
expect_identical(result_feather, result_ipc)
329337
})
330338

331339
test_that("Can read Feather files from a URL", {

r/tests/testthat/test-metadata.R

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -260,20 +260,20 @@ test_that("R metadata roundtrip via parquet", {
260260
expect_identical(read_parquet(tf), example_with_metadata)
261261
})
262262

263-
test_that("R metadata roundtrip via feather", {
263+
test_that("R metadata roundtrip via IPC", {
264264
tf <- tempfile()
265265
on.exit(unlink(tf))
266266

267-
write_feather(example_with_metadata, tf)
268-
expect_identical(read_feather(tf), example_with_metadata)
267+
write_ipc_file(example_with_metadata, tf)
268+
expect_identical(read_ipc_file(tf), example_with_metadata)
269269
})
270270

271-
test_that("haven types roundtrip via feather", {
271+
test_that("haven types roundtrip via IPC", {
272272
tf <- tempfile()
273273
on.exit(unlink(tf))
274274

275-
write_feather(haven_data, tf)
276-
expect_identical(read_feather(tf), haven_data)
275+
write_ipc_file(haven_data, tf)
276+
expect_identical(read_ipc_file(tf), haven_data)
277277
})
278278

279279
test_that("Date/time type roundtrip", {

r/tests/testthat/test-read-record-batch.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ test_that("RecordBatchFileWriter / RecordBatchFileReader roundtrips", {
3737
writer$close()
3838
stream$close()
3939

40-
expect_equal(read_feather(tf, as_data_frame = FALSE, mmap = FALSE), tab)
40+
expect_equal(read_ipc_file(tf, as_data_frame = FALSE, mmap = FALSE), tab)
4141
# Make sure connections are closed
4242
expect_error(file.remove(tf), NA)
4343
skip_on_os("windows") # This should pass, we've closed the stream

r/tests/testthat/test-read-write.R

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,9 @@ test_that("table round trip", {
6565
expect_equal(chunked_array_raw$chunk(i - 1L), chunks_raw[[i]])
6666
}
6767
tf <- tempfile()
68-
write_feather(tbl, tf)
68+
write_ipc_file(tbl, tf)
6969

70-
res <- read_feather(tf)
70+
res <- read_ipc_file(tf)
7171
expect_identical(tbl$int, res$int)
7272
expect_identical(tbl$dbl, res$dbl)
7373
expect_identical(as.integer(tbl$raw), res$raw)
@@ -98,9 +98,9 @@ test_that("table round trip handles NA in integer and numeric", {
9898
expect_equal(tab$column(2)$type, uint8())
9999

100100
tf <- tempfile()
101-
write_feather(tbl, tf)
101+
write_ipc_file(tbl, tf)
102102

103-
res <- read_feather(tf)
103+
res <- read_ipc_file(tf)
104104
expect_identical(tbl$int, res$int)
105105
expect_identical(tbl$dbl, res$dbl)
106106
expect_identical(as.integer(tbl$raw), res$raw)

0 commit comments

Comments
 (0)