paleolimbot commented on code in PR #14922:
URL: https://github.com/apache/arrow/pull/14922#discussion_r1058010293
##########
r/R/array.R:
##########
@@ -450,6 +440,44 @@ StructArray <- R6Class("StructArray",
)
)
+StructArray$create <- function(...) {
+ dots <- list2(...)
Review Comment:
I'm sorry for forgetting about this thread! I think Will nailed it...the
easiest way around `record_batch()`'s auto-splicing of data.frames from unnamed
arguments thing is just to give all the arguments names. Maybe using
`rlang::dots_list(..., .named = TRUE)`?
``` r
library(arrow, warn.conflicts = FALSE)
struct_array <- function(...) {
args <- rlang::dots_list(..., .named = TRUE)
batch <- record_batch(!!! args)
array_ptr <- arrow:::allocate_arrow_array()
schema_ptr <- arrow:::allocate_arrow_schema()
batch$export_to_c(array_ptr, schema_ptr)
Array$import_from_c(array_ptr, schema_ptr)
}
struct_array(Array$create(1), Array$create(2))
#> StructArray
#> <struct<Array$create(1): double, Array$create(2): double>>
#> -- is_valid: all not null
#> -- child 0 type: double
#> [
#> 1
#> ]
#> -- child 1 type: double
#> [
#> 2
#> ]
```
<sup>Created on 2022-12-27 with [reprex
v2.0.2](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]