Skip to content

Commit dfd08cb

Browse files
Add failing tests
1 parent 81ce081 commit dfd08cb

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

r/tests/testthat/helper-parquet.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@
1515
# specific language governing permissions and limitations
1616
# under the License.
1717

18-
expect_parquet_roundtrip <- function(tab, ...) {
18+
expect_parquet_roundtrip <- function(tab, ..., as_data_frame = FALSE) {
1919
tf <- tempfile()
2020
on.exit(unlink(tf))
2121

2222
write_parquet(tab, tf, ...)
23-
expect_equal(read_parquet(tf, as_data_frame = FALSE), tab)
23+
expect_equal(read_parquet(tf, as_data_frame = as_data_frame), tab)
2424
}

r/tests/testthat/test-parquet.R

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,3 +106,13 @@ test_that("write_parquet() defaults to snappy compression", {
106106
write_parquet(mtcars, tmp2, compression = "snappy")
107107
expect_equal(file.size(tmp1), file.size(tmp2))
108108
})
109+
110+
test_that("Factors are preserved when writing/reading from Parquet", {
111+
fct <- factor(c("a", "b"), levels = c("c", "a", "b"))
112+
ord <- factor(c("a", "b"), levels = c("c", "a", "b"), ordered = TRUE)
113+
chr <- c("a", "b")
114+
df <- tibble::tibble(fct = fct, ord = ord, chr = chr)
115+
116+
expect_parquet_roundtrip(df)
117+
expect_parquet_roundtrip(df, as_data_frame = FALSE)
118+
})

0 commit comments

Comments
 (0)