You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Support interval mul / div double arithmetic #9030
Is your feature request related to a problem or challenge? Please describe what you are trying to do.
As part of updating Datafusion to better support date / time math operations (apache/datafusion#19022 among others) it was uncovered that arrow-rs does not support interval * / number ops that should be valid.
Multiplication I think is reasonable, division I can see causing some issues
In particular what is 1 day / 3? 0 day? Unfortunately a day is not consistently 24 hours courtesy of DST. Do we just error?
I also think we should probably only support Int64 and rely on query engines coercion machinery, otherwise we'll end up generating a load of code for what is a relatively niche use-case.
When adding an interval value to (or subtracting an interval value from) a timestamp with time zone value, the days component advances (or decrements) the date of the timestamp with time zone by the indicated number of days. Across daylight saving time changes (with the session time zone set to a time zone that recognizes DST), this means interval '1 day' does not necessarily equal interval '24 hours'. For example, with the session time zone set to CST7CDT, timestamp with time zone '2005-04-02 12:00-07' + interval '1 day' will produce timestamp with time zone '2005-04-03 12:00-06', while adding interval '24 hours' to the same initial timestamp with time zone produces timestamp with time zone '2005-04-03 13:00-06', as there is a change in daylight saving time at 2005-04-03 02:00 in time zone CST7CDT.
However, in this issue the interval isn't related to anything that has a timezone so I think that mapping a day to 24 hours is reasonable. I believe postgresql treats it exactly that way too:
Currently with df/arrow it looks like it's handled correctly:
Yes, and a lot of effort has gone into making it work correctly
However, in this issue the interval isn't related to anything that has a timezone so I think that mapping a day to 24 hours is reasonable. I believe postgresql treats it exactly that way too:
The point is that an interval can be used with dates with timezones, so it is incorrect to treat days and hours as interchangeable. If you want that behaviour you should just use a duration type 😄
When doing addition or subtraction I completely agree. However I don't think that is the case for mul and div as it's only applicably to this small feature - it makes no sense otherwise.
Activity
tustvold commentedon Dec 22, 2025
Multiplication I think is reasonable, division I can see causing some issues
In particular what is
1 day / 3?0 day? Unfortunately a day is not consistently 24 hours courtesy of DST. Do we just error?I also think we should probably only support Int64 and rely on query engines coercion machinery, otherwise we'll end up generating a load of code for what is a relatively niche use-case.
Omega359 commentedon Dec 22, 2025
Currently with df/arrow it looks like it's handled correctly:
This aligns with postgresql:
However, in this issue the interval isn't related to anything that has a timezone so I think that mapping a day to 24 hours is reasonable. I believe postgresql treats it exactly that way too:
tustvold commentedon Dec 22, 2025
Yes, and a lot of effort has gone into making it work correctly
The point is that an interval can be used with dates with timezones, so it is incorrect to treat days and hours as interchangeable. If you want that behaviour you should just use a duration type 😄
Omega359 commentedon Dec 22, 2025
When doing addition or subtraction I completely agree. However I don't think that is the case for mul and div as it's only applicably to this small feature - it makes no sense otherwise.
peterxcli commentedon Jul 13, 2026
take
peterxcli commentedon Jul 13, 2026
I think I will first submit the pr for multiply with integer so above problem won't appear.
peterxcli commentedon Jul 14, 2026
Hi, I opened a PR for interval multiplication with integer: #10336, which I think would be easy to review and no time unit issue mentioned above.
Add interval multiplication by i64 (#10336)
Add interval mul/div support for Float64 (apache#10409)