paleolimbot opened a new pull request, #692:
URL: https://github.com/apache/arrow-nanoarrow/pull/692
Still needs some testing on the stream case, and is unfortunately not very
zero copy; however, gets the job done (and I think fixes some cases where we
would have otherwise silently handled a matrix as the storage type).
Inspired by #691!
``` r
library(nanoarrow)
df <- data.frame(x = 1:10)
df$matrix_col <- matrix(letters[1:20], ncol = 2, byrow = TRUE)
array <- as_nanoarrow_array(df)
# Default comes back as list_of(character())
convert_array(array) |> tibble::as_tibble()
#> # A tibble: 10 × 2
#> x matrix_col
#> <int> <list<chr>>
#> 1 1 [2]
#> 2 2 [2]
#> 3 3 [2]
#> 4 4 [2]
#> 5 5 [2]
#> 6 6 [2]
#> 7 7 [2]
#> 8 8 [2]
#> 9 9 [2]
#> 10 10 [2]
# But can specify matrix
convert_array(
array,
tibble::tibble(x = integer(), matrix_col = matrix(character(), ncol = 2))
)
#> # A tibble: 10 × 2
#> x matrix_col[,1] [,2]
#> <int> <chr> <chr>
#> 1 1 a b
#> 2 2 c d
#> 3 3 e f
#> 4 4 g h
#> 5 5 i j
#> 6 6 k l
#> 7 7 m n
#> 8 8 o p
#> 9 9 q r
#> 10 10 s t
```
<sup>Created on 2024-12-12 with [reprex
v2.1.1](https://reprex.tidyverse.org)</sup>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]