Uploaded image for project: 'Apache Arrow'
  1. Apache Arrow
  2. ARROW-18337

[R] Possible undesirable handling of POSIXlt objects

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • None
    • 11.0.0
    • R

    Description

      In the course of updating documentation, I noticed that it is possible to create an Arrow array of POSIXlt objects from R, but not a scalar.

      https://github.com/apache/arrow/pull/14514#discussion_r1016078081

      This works:

      tm <- as.POSIXlt(c(Sys.time(), Sys.time()))
      arrow::Array$create(tm)
      

      This fails:

      arrow::Scalar$create(as.POSIXlt(Sys.time()))
      

      It's possible to manually convert a POSIXlt object to a struct scalar like this:

      df <- as.data.frame(unclass(as.POSIXlt(Sys.time())))
      arrow::Scalar$create(df, 
                    type = struct(
                      sec = float32(), 
                      min = int32(),
                      hour = int32(),
                      mday = int32(),
                      mon = int32(),
                      year = int32(),
                      wday = int32(),
                      yday = int32(),
                      isdst = int32(),
                      zone = utf8(),
                      gmtoff = int32()
                    ))
      

      although this does not seem precisely the same as the behaviour of Array$create() which creates an extension type?

      It was unclear to us (thisisnic and myself) whether the current behaviour was desirable, so it seemed sensible to open an issue!

      Related issue:

      https://issues.apache.org/jira/browse/ARROW-18263

      Attachments

        Issue Links

          Activity

            People

              paleolimbot Dewey Dunnington
              djnavarro Danielle Navarro
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 40m
                  40m