[ 
https://issues.apache.org/jira/browse/ARROW-15919?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17505042#comment-17505042
 ] 

Rok Mihevc commented on ARROW-15919:
------------------------------------

Yeah I was just thinking subtract doesn't make sense. Thanks for pointing it 
out.

> [C++] Add_kernel not commutative with timestamps & duration maths
> -----------------------------------------------------------------
>
>                 Key: ARROW-15919
>                 URL: https://issues.apache.org/jira/browse/ARROW-15919
>             Project: Apache Arrow
>          Issue Type: Sub-task
>          Components: C++
>            Reporter: Dragoș Moldovan-Grünfeld
>            Assignee: Rok Mihevc
>            Priority: Blocker
>
> 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
> {code:r}
> 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)
> {code}



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

Reply via email to