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

[R] How to round the timestamps in a mutate statement?

    XMLWordPrintableJSON

Details

    • Wish
    • Status: Closed
    • Minor
    • Resolution: Duplicate
    • 7.0.0
    • None
    • R
    • None

    Description

      I was trying to aggregate over time using different granularity. Usually I would use the lubridate::floor_date() , which is currently not supported for parquet datasets.

      Is there any comprehensive list of supported list of currently supported lubridate (or dplyr) verbs? Maybe, it’s only my fault, but except the changelog I haven’t find any relevant information.

       

      Later I found that the round_temporal() function is exposed to R
      But I am struggling to find the right syntax inside a mutate statement to apply on a timestamp[us, tz=UTC] type column.

      new_dataset |>
        mutate(time = arrow_round_temporal(time))
      #>  Error: Invalid: Attempted to initialize KernelState from null FunctionOptions
      

       

      Here are some other attempts:

      library(arrow)
      
      arrow_now <- Scalar$create(lubridate::now())
      (arrow_now)
      #> Scalar
      #> 2022-04-25 11:44:33.805609
      call_function("round_temporal", arrow_now)
      #> Scalar
      #> 2022-04-25 00:00:00.000000
      call_function("round_temporal", arrow_now, unit = "day")
      #> Error: Argument 2 is of class character but it must be one of "Array", "ChunkedArray", "RecordBatch", "Table", or "Scalar"
      arrow_unit <- Scalar$create("day")
      (arrow_unit)
      #> Scalar
      #> day
      call_function("round_temporal", arrow_now, unit = arrow_unit)
      #> Error: Invalid: Function 'round_temporal' accepts 1 arguments but attempted to look up kernel(s) with 2
      

       

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              kbzsl Zsolt Kegyes-Brassai
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: