Skip to content

Commit

Permalink
ARROW-7690 [R] Cannot write parquet to OutputStream
Browse files Browse the repository at this point in the history
The second parameter for inherits expects a character vector.

Closes #6304 from bob-skowron/ISS-ARROW-7690 and squashes the following commits:

6e36916 <Neal Richardson> Add test
af61d4c <Bob Skowron> the second parameter for inherits expects a character vector

Lead-authored-by: Bob Skowron <[email protected]>
Co-authored-by: Neal Richardson <[email protected]>
Co-authored-by: Bob Skowron <%email_address%>
Signed-off-by: Neal Richardson <[email protected]>
  • Loading branch information
bob-skowron and nealrichardson committed Jan 28, 2020
1 parent d609376 commit 8b7911b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion r/R/parquet.R
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ write_parquet <- function(x,
if (is.character(sink)) {
sink <- FileOutputStream$create(sink)
on.exit(sink$close())
} else if (!inherits(sink, OutputStream)) {
} else if (!inherits(sink, "OutputStream")) {
abort("sink must be a file path or an OutputStream")
}

Expand Down
10 changes: 10 additions & 0 deletions r/tests/testthat/test-parquet.R
Original file line number Diff line number Diff line change
Expand Up @@ -120,3 +120,13 @@ test_that("Factors are preserved when writing/reading from Parquet", {
df_read <- read_parquet(pq_tmp_file)
expect_identical(df, df_read)
})

test_that("write_parquet() to stream", {
df <- tibble::tibble(x = 1:5)
tf <- tempfile()
con <- FileOutputStream$create(tf)
on.exit(unlink(tf))
write_parquet(df, con)
con$close()
expect_equal(read_parquet(tf), df)
})

0 comments on commit 8b7911b

Please sign in to comment.