You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@arrow.apache.org by "ASF GitHub Bot (Jira)" <ji...@apache.org> on 2022/12/12 18:08: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 ]

ASF GitHub Bot updated ARROW-16266:
-----------------------------------
    Labels: pull-request-available  (was: )

> [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
>            Assignee: Nicola Crane
>            Priority: Critical
>              Labels: pull-request-available
>             Fix For: 11.0.0
>
>          Time Spent: 10m
>  Remaining Estimate: 0h
>
> 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)