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

Rok Mihevc edited comment on ARROW-14108 at 2/23/22, 3:12 PM:
--------------------------------------------------------------

[~jorisvandenbossche] I agree that we could use `day_time_interval_between` as 
an intermediate step.

The reason for a lot of boiler plate here is lack (as far as I understand) of 
templates for kernels with StructArray output. Even if doing `cast(day_hours, 
day_time_interval_between(ts_arr0, ts_arr1))` we would need some of it. 
Although there would be less due to that cast being a unary kernel. Perhaps we 
could even abstract out a template and reuse it on ISOCalendar and YearMonthDay 
kernels.

Either way I would be perhaps be useful to hear about Westons usecase. 
[~westonpace]


was (Author: rokm):
[~jorisvandenbossche] I agree that we could use `day_time_interval_between` as 
an intermediate step.

The reason for a lot of boiler plate here is lack (as far as I understand) of 
templates for kernels with StructArray output. Even if doing `cast(day_hours, 
day_time_interval_between(ts_arr0, ts_arr1))` we would need some of it. 
Although there would be less due to that cast being a unary kernel. Perhaps we 
could even abstract out a template and reuse it on ISOCalendar and YearMonthDay 
kernels.

Either way I would be perhaps be useful to hear about Westons usecase.

> [C++] interval_between(timestamptz, timestamptz) -> struct kernel
> -----------------------------------------------------------------
>
>                 Key: ARROW-14108
>                 URL: https://issues.apache.org/jira/browse/ARROW-14108
>             Project: Apache Arrow
>          Issue Type: Sub-task
>          Components: C++
>            Reporter: Weston Pace
>            Assignee: Rok Mihevc
>            Priority: Major
>              Labels: pull-request-available
>          Time Spent: 0.5h
>  Remaining Estimate: 0h
>
> Given two timestamps that each have time zones this function should return an 
> interval from the first timestamp to the second timestamp according to the 
> following rules (postgres rules):
> * 1 day is 24 physical hours (which may not exactly equal 1 calendar day).
> * Intervals returned will never contain a months/years field
> Examples:
> interval_between('2021-03-14 00:00:00 America/Denver', '2021-03-15 00:00:00 
> America/Denver') => { "hours": 23 }
> interval_between('2021-03-14 00:00:00 UTC', '2021-03-15 00:00:00 UTC') => { 
> "days": 1}
> interval_between('2021-03-14 00:00:00 UTC', '2020-03-14 00:00:00 UTC') => { 
> "days": 365}
> If the first timestamp is larger than the second timestamp then the interval 
> will be negative.



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

Reply via email to