arrow_extendr
Pass arrow-rs objects to and from an R session
Motivating Example
Say we have the following DBI connection which we will send requests to using arrow.
The result of dbGetQueryArrow() is a nanoarrow_array_stream. We want to
count the number of rows in each batch of the steam using Rust.
# adapted from https://github.com/r-dbi/DBI/blob/main/vignettes/DBI-arrow.Rmd
con <-
data <-
We can write an extendr function which creates an ArrowArrayStreamReader
from an &Robj. In the function we instantiate a counter to keep track
of the number of rows per chunk. For each chunk we print the number of rows.
/// @export
With this function we can use it on the output of dbGetQueryArrow() or other Arrow
related DBI functions.
query <-
#> Processing `ArrowArrayStreamReader`...
#> Found 256 rows
#> Found 256 rows
#> Found 256 rows
#> ... truncated ...
#> Found 256 rows
#> Found 256 rows
#> Found 143 rows
#> [1] 2959