You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@arrow.apache.org by "Dragoș Moldovan-Grünfeld (Jira)" <ji...@apache.org> on 2022/03/11 16:36:00 UTC

[jira] [Commented] (ARROW-15919) [C++] Add_kernel not commutative with timestamps & duration maths

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

Dragoș Moldovan-Grünfeld commented on ARROW-15919:
--------------------------------------------------

[~rokm] I think this might be the case with some of the other temporal arithmetic kernels too.

> [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: Bug
>          Components: C++
>            Reporter: Dragoș Moldovan-Grünfeld
>            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)