Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support Interval +/- Interval #4179

Closed
wants to merge 1 commit into from
Closed

feat: support Interval +/- Interval #4179

wants to merge 1 commit into from

Conversation

izveigor
Copy link
Contributor

@izveigor izveigor commented May 6, 2023

Which issue does this PR close?

Closes #4178.

Rationale for this change

What changes are included in this PR?

Are there any user-facing changes?

Yes

@github-actions github-actions bot added the arrow Changes to the arrow crate label May 6, 2023
Copy link
Contributor

@tustvold tustvold left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you perhaps expand on the use-case for arithmetic between heterogenous interval types, we don't provide this for other types, instead leaving this to type coercion logic? You can't for example add Int16 to Int32

@izveigor
Copy link
Contributor Author

izveigor commented May 8, 2023

Hello, @tustvold!
I agree with the fact, that cast function can replace add_dyn between different types in the same group (like Int16 + Int32).
But, the cast function does not support Intervals. See the problem: #4181
Even if the implementation is done in code, in my opinion, adding different types of intervals can make life easier (for example, if you need to add a day (DayTimeType) to the year (YearMonthType), you get a ready-made type with ready-made calculations, instead of translating two data types into a third (MonthDayNanoType) and producing calculations)

@tustvold
Copy link
Contributor

tustvold commented May 8, 2023

I will try to find time to review #4182 tomorrow, I think this is the best path forward for this, as it avoids the somewhat unclear semantics of heterogenous interval addition, whilst also being less code and more consistent.

you need to add a day (DayTimeType) to the year (YearMonthType)

But should the output be DayTimeType, potentially overflowing and having to make assumptions about days in a month, or YearMonthType, potentially truncating, or should it be MonthDayNano? I suspect arguments could be made for all three, its simpler and more consistent to just not take a side 😅

@izveigor
Copy link
Contributor Author

izveigor commented May 9, 2023

Your argument seems reasonable. "Cast method" gives user more options than "Add method".
Thanks for your work, @tustvold!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
arrow Changes to the arrow crate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support Interval +/- Interval
2 participants