XMLWordPrintableJSON

Details

    • Sub-task
    • Status: Resolved
    • Blocker
    • Resolution: Fixed
    • None
    • 8.0.0
    • C++

    Description

      A + B != B + A when it comes to adding duration to timestamp, for example.

      Should add(timestamp, duration) == add(duration, timestamp)? Or, in other words, should the order matter?

      This has surfaced in R when creating some of the lubridate bindings - see non-lubridate example below

      a <- ymd("2009-08-03", tz = "America/Chicago")
      a_array <- Array$create(rep(a, 12))
      
      b_array <- Array$create((1:12)*86400L)$cast(time32(unit = "s")) - 
        Array$create(rep(0L, 12))$cast(time32(unit = "s"))
      
      a_array
      a_array
      Array
      <timestamp[us, tz=America/Chicago]>
      [
        2009-08-03 05:00:00.000000,
        2009-08-03 05:00:00.000000,
        2009-08-03 05:00:00.000000,
        2009-08-03 05:00:00.000000,
        2009-08-03 05:00:00.000000,
        2009-08-03 05:00:00.000000,
        2009-08-03 05:00:00.000000,
        2009-08-03 05:00:00.000000,
        2009-08-03 05:00:00.000000,
        2009-08-03 05:00:00.000000,
        2009-08-03 05:00:00.000000,
        2009-08-03 05:00:00.000000
      ]
      
      b_array
      Array
      <duration[s]>
      [
        86400,
        172800,
        259200,
        345600,
        432000,
        518400,
        604800,
        691200,
        777600,
        864000,
        950400,
        1036800
      ]
      
      a_array + b_array
      Array
      <timestamp[us, tz=America/Chicago]>
      [
        2009-08-04 05:00:00.000000,
        2009-08-05 05:00:00.000000,
        2009-08-06 05:00:00.000000,
        2009-08-07 05:00:00.000000,
        2009-08-08 05:00:00.000000,
        2009-08-09 05:00:00.000000,
        2009-08-10 05:00:00.000000,
        2009-08-11 05:00:00.000000,
        2009-08-12 05:00:00.000000,
        2009-08-13 05:00:00.000000,
        2009-08-14 05:00:00.000000,
        2009-08-15 05:00:00.000000
      ]
      
      b_array + a_array
       Error: NotImplemented: Function 'add_checked' has no kernel matching input types (array[duration[us]], array[timestamp[us, tz=America/Chicago]])
      /Users/dragos/Documents/arrow/cpp/src/arrow/compute/function.cc:231 DispatchBest(&inputs)
      

      Attachments

        Issue Links

          Activity

            People

              rokm Rok Mihevc
              dragosmg Dragoș Moldovan-Grünfeld
              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 - 3h 10m
                  3h 10m