Skip to content

Commit

Permalink
test: add more tests for arrow package
Browse files Browse the repository at this point in the history
  • Loading branch information
eitsupi committed Jan 21, 2024
1 parent 34d9cb9 commit a453b83
Showing 1 changed file with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion tests/testthat/test-as_polars.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ make_as_polars_df_cases = function() {
"polars_lazy_rolling_group_by", pl$LazyFrame(test_df)$rolling("col_int", period = "1i"),
"polars_group_by_dynamic", pl$DataFrame(test_df)$group_by_dynamic("col_int", every = "1i"),
"polars_lazy_group_by_dynamic", pl$LazyFrame(test_df)$group_by_dynamic("col_int", every = "1i"),
"arrow Table", arrow::as_arrow_table(test_df)
"arrow Table", arrow::as_arrow_table(test_df),
"arrow RecordBatch", arrow::as_record_batch(test_df),
)
}

Expand Down Expand Up @@ -166,3 +167,31 @@ test_that("tests for vctrs_rcrd", {
c(2L, 1L)
)
})


test_that("can convert an arrow Table contains dictionary<large_string, uint32> type", {
skip_if_not_installed("arrow")

da_string = arrow::Array$create(
factor(c("x", "y", "z"))
)

da_large_string = da_string$cast(
arrow::dictionary(
index_type = arrow::uint32(),
value_type = arrow::large_utf8()
)
)

at = arrow::arrow_table(foo = da_string, bar = da_large_string)
pdf = as_polars_df.ArrowTabular(at)

expect_s3_class(pdf, "RPolarsDataFrame")
expect_equal(
pdf$to_data_frame(),
data.frame(
foo = factor(c("x", "y", "z")),
bar = factor(c("x", "y", "z"))
)
)
})

0 comments on commit a453b83

Please sign in to comment.