You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@arrow.apache.org by "Nicola Crane (Jira)" <ji...@apache.org> on 2022/10/27 13:05:00 UTC

[jira] [Updated] (ARROW-16266) [R] Add StructArray$create()

     [ https://issues.apache.org/jira/browse/ARROW-16266?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Nicola Crane updated ARROW-16266:
---------------------------------
    Priority: Critical  (was: Major)

> [R] Add StructArray$create()
> ----------------------------
>
>                 Key: ARROW-16266
>                 URL: https://issues.apache.org/jira/browse/ARROW-16266
>             Project: Apache Arrow
>          Issue Type: Improvement
>          Components: R
>            Reporter: Dewey Dunnington
>            Priority: Critical
>
> In ARROW-13371 we implemented the {{make_struct}} compute function bound to {{data.frame()}} / {{tibble()}} in dplyr evaluation; however, we didn't actually implement {{StructArray$create()}}. In ARROW-15168, it turns out that we need to do this to support {{StructArray}} creation from data.frames whose columns aren't all convertable using the internal C++ conversion. The hack used in that PR is below (but we should clearly implement the C++ function instead of using the hack):
> {code:R}
> library(arrow, warn.conflicts = FALSE)
> struct_array <- function(...) {
>   batch <- record_batch(...)
>   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(a = 1, b = "two")
> #> StructArray
> #> <struct<a: double, b: string>>
> #> -- is_valid: all not null
> #> -- child 0 type: double
> #>   [
> #>     1
> #>   ]
> #> -- child 1 type: string
> #>   [
> #>     "two"
> #>   ]
> {code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)