You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@arrow.apache.org by "Neal Richardson (Jira)" <ji...@apache.org> on 2020/05/19 22:10:00 UTC

[jira] [Created] (ARROW-8867) [R] Support converting POSIXlt type; named lists in general

Neal Richardson created ARROW-8867:
--------------------------------------

             Summary: [R] Support converting POSIXlt type; named lists in general
                 Key: ARROW-8867
                 URL: https://issues.apache.org/jira/browse/ARROW-8867
             Project: Apache Arrow
          Issue Type: New Feature
          Components: R
            Reporter: Neal Richardson
             Fix For: 1.0.0


{code:r}
f <- as.POSIXlt(Sys.time() + 1:5)
Array$create(f)
# Error in Array__from_vector(x, type) : 
#   Unknown: List vector expecting elements vector of type double but got int32
{code}

Issue #1: POSIXlt type is a struct, essentially. But because it is not a data.frame, we don't try to convert it to a struct. (We should probably convert named lists to structs and not list type in general.)

If I trick the converter into thinking it is a data.frame, it will convert to struct successfully.

{code:r}
class(f) <- c(class(f), "data.frame")
Array$create(f)
# StructArray
# <struct<sec: double, min: int32, hour: int32, mday: int32, mon: int32, year: int32, wday: int32, yday: int32, isdst: int32, zone: string, gmtoff: int32>>
# ...
{code}

Issue #2: round trip won't work because the attributes that tell you that this struct is a POSIXlt type, what time zone it is, etc., are dropped. This would be helped by storing those attributes as custom_metadata on the Table. (We could also implement it as an extension type, but if it's just for going back and forth between R, would that have any benefit?)



--
This message was sent by Atlassian Jira
(v8.3.4#803005)