Skip to content

Commit

Permalink
fix most failures [skip ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
etiennebacher committed Sep 14, 2024
1 parent 1443412 commit b680408
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 15 deletions.
4 changes: 2 additions & 2 deletions R/as_polars.R
Original file line number Diff line number Diff line change
Expand Up @@ -383,14 +383,14 @@ as_polars_series.POSIXlt = function(x, name = NULL, ...) {
#' @rdname as_polars_series
#' @export
as_polars_series.data.frame = function(x, name = NULL, ...) {
as_polars_df(x)$to_struct(name = name)
as_polars_df(x)$to_struct(name = name %||% "")
}


#' @rdname as_polars_series
#' @export
as_polars_series.vctrs_rcrd = function(x, name = NULL, ...) {
pl$select(unclass(x))$to_struct(name = name)
pl$select(unclass(x))$to_struct(name = name %||% "")
}


Expand Down
1 change: 0 additions & 1 deletion R/io_ipc.R
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ pl_scan_ipc = function(
rechunk = rechunk,
row_name = row_index_name,
row_index = row_index_offset,
memory_map = memory_map,
hive_partitioning = hive_partitioning,
hive_schema = hive_schema,
try_parse_hive_dates = try_parse_hive_dates,
Expand Down
8 changes: 3 additions & 5 deletions tests/testthat/_snaps/lazy.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
FILTER [(col("a")) == (2)] FROM
DF ["a", "b"]; PROJECT */2 COLUMNS; SELECTION: None

# LazyFrame serialize/deseialize
# LazyFrame serialize/deserialize

Code
jsonlite::prettify(json)
Expand Down Expand Up @@ -51,13 +51,11 @@
]
},
"schema": {
"inner": {
"fields": {
"a": "Int32",
"b": "String"
}
},
"output_schema": null,
"filter": null
}
}
},
"predicate": {
Expand Down
1 change: 0 additions & 1 deletion tests/testthat/test-ipc.R
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ test_that("Test reading data from Apache Arrow IPC", {
expect_grepl_error(pl$scan_ipc(tmpf, rechunk = list()))
expect_grepl_error(pl$scan_ipc(tmpf, row_index_name = c("x", "y")))
expect_grepl_error(pl$scan_ipc(tmpf, row_index_name = "name", row_index_offset = data.frame()))
expect_grepl_error(pl$scan_ipc(tmpf, memory_map = NULL))
})


Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/test-lazy.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ test_that("create LazyFrame", {
})


test_that("LazyFrame serialize/deseialize", {
test_that("LazyFrame serialize/deserialize", {
skip_if_not_installed("jsonlite")

df = pl$DataFrame(
Expand All @@ -48,7 +48,7 @@ test_that("LazyFrame serialize/deseialize", {
df$lazy()$select(
pl$col("a")$map_elements(\(x) -abs(x))
)$serialize(),
"serialize not supported for this 'opaque' function"
"serialization not supported for this 'opaque' function"
)
})

Expand Down
8 changes: 4 additions & 4 deletions tests/testthat/test-sink_stream.R
Original file line number Diff line number Diff line change
Expand Up @@ -49,27 +49,27 @@ test_that("Test sinking data to IPC file", {
on.exit(unlink(tmpf))
lf$sink_ipc(tmpf)
expect_grepl_error(lf$sink_ipc(tmpf, compression = "rar"))
expect_identical(pl$scan_ipc(tmpf, memory_map = FALSE)$collect()$to_data_frame(), rdf)
expect_identical(pl$scan_ipc(tmpf)$collect()$to_data_frame(), rdf)


# update with new data
lf$slice(5, 5)$sink_ipc(tmpf)
expect_equal(
pl$scan_ipc(tmpf, memory_map = FALSE)$collect()$to_data_frame(),
pl$scan_ipc(tmpf)$collect()$to_data_frame(),
lf$slice(5, 5)$collect()$to_data_frame()
)
lf$sink_ipc(tmpf)

# from another process via rcall
rdf_callr = callr::r(\(tmpf) {
polars::pl$scan_ipc(tmpf, memory_map = FALSE)$collect()$to_data_frame()
polars::pl$scan_ipc(tmpf)$collect()$to_data_frame()
}, args = list(tmpf = tmpf))
expect_identical(rdf_callr, rdf)


# from another process via rpool
f_ipc_to_s = \(s) {
polars::pl$scan_ipc(s$to_r(), memory_map = FALSE)$
polars::pl$scan_ipc(s$to_r())$
select(polars::pl$struct(polars::pl$all()))$
collect()$
to_series()
Expand Down

0 comments on commit b680408

Please sign in to comment.