You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@arrow.apache.org by "Dewey Dunnington (Jira)" <ji...@apache.org> on 2021/11/24 13:12:00 UTC

[jira] [Created] (ARROW-14828) [R] Smooth out handling of data.frame and StructScalar

Dewey Dunnington created ARROW-14828:
----------------------------------------

             Summary: [R] Smooth out handling of data.frame and StructScalar
                 Key: ARROW-14828
                 URL: https://issues.apache.org/jira/browse/ARROW-14828
             Project: Apache Arrow
          Issue Type: Improvement
          Components: R
            Reporter: Dewey Dunnington


Currently we have 

{code:R}
arrow::Array$create(data.frame(col = 1:2))
#> StructArray
#> <struct<col: int32>>
#> -- is_valid: all not null
#> -- child 0 type: int32
#>   [
#>     1,
#>     2
#>   ]
{code}


…and 

{code:R}
arrow::Scalar$create(data.frame(col = 1L))
#> StructScalar
#> {col:int32 = 1}
{code}


…but Scalar truncates the data.frame to the first row without warning 

{code:R}
arrow::Scalar$create(data.frame(col = 1:2))
#> StructScalar
#> {col:int32 = 1}
as.vector(arrow::Scalar$create(data.frame(col = 1:2)))
#> # A tibble: 1 × 1
#>     col
#>   <int>
#> 1     1
{code}


…and there is no {{as.data.frame()}} method for the scalar type (whereas there is {{as.integer()}} and family and {{as.data.frame()}} for the StructArray type) 

{code:R}
as.data.frame(arrow::Scalar$create(data.frame(col = 1L)))
#> Error in as.data.frame.default(arrow::Scalar$create(data.frame(col = 1L))): cannot coerce class 'c("StructScalar", "Scalar", "ArrowDatum", "ArrowObject", "R6"' to a data.frame
as.data.frame(arrow::Array$create(data.frame(col = 1L)))
#> # A tibble: 1 × 1
#>     col
#>   <int>
#> 1     1
as.integer(arrow::Scalar$create(1L))
#> [1] 1
{code}




--
This message was sent by Atlassian Jira
(v8.20.1#820001)