Details
-
Bug
-
Status: Resolved
-
Critical
-
Resolution: Fixed
-
None
Description
This issue surfaced in R. Subtraction between a timestamp and a date only errors when the date is Date32 and the timestamp is expressed in seconds.
While I understand the subtract kernel doesn't natively support operations between the various temporal types and some magic (aka implicit casting) is taking place (via DispatchBest), I think this is an unexpected behaviour. If Date32 (expressed in days) cannot be converted into seconds, then I would expect all combinations of Date32 and timestamp units to fail. I hope this makes sense.
Reprex:
a <- Array$create(as.Date("2022-03-25")) b <- Array$create(as.POSIXct("2022-03-26")) # it only errors when a is date32() and b is timestamp("s") a$cast(date32()) - b$cast(timestamp("s")) #> Error: NotImplemented: Function 'subtract_checked' has no kernel matching input types (array[date32[day]], array[timestamp[s]]) #> /Users/dragos/Documents/arrow/cpp/src/arrow/compute/function.cc:231 DispatchBest(&inputs) # it works fine in all other cases a$cast(date32()) - b$cast(timestamp("ms")) #> Array #> <duration[ms]> #> [ #> -86400000 #> ] a$cast(date32()) - b$cast(timestamp("us")) #> Array #> <duration[us]> #> [ #> -86400000000 #> ] a$cast(date32()) - b$cast(timestamp("ns")) #> Array #> <duration[ns]> #> [ #> -86400000000000 #> ] # a is date64() and b is timestamp() a$cast(date64()) - b$cast(timestamp("s")) #> Array #> <duration[ms]> #> [ #> -86400000 #> ] a$cast(date64()) - b$cast(timestamp("ms")) #> Array #> <duration[ms]> #> [ #> -86400000 #> ] a$cast(date64()) - b$cast(timestamp("us")) #> Array #> <duration[us]> #> [ #> -86400000000 #> ] a$cast(date64()) - b$cast(timestamp("ns")) #> Array #> <duration[ns]> #> [ #> -86400000000000 #> ]
Attachments
Issue Links
- links to