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

Incorrect Numeric operations on MONTH_DAY_NANO interval type #1065

Closed
Tracked by #3148
alamb opened this issue Dec 20, 2021 · 1 comment · Fixed by #4493
Closed
Tracked by #3148

Incorrect Numeric operations on MONTH_DAY_NANO interval type #1065

alamb opened this issue Dec 20, 2021 · 1 comment · Fixed by #4493
Assignees
Labels
arrow Changes to the arrow crate bug

Comments

@alamb
Copy link
Contributor

alamb commented Dec 20, 2021

Describe the bug
Pointed out by @jorgecarleitao and @b41sh on #779 (comment)

Semantically, the numerics of an i128 are not the same as the numerics of (months,days,nanos) since i128 + i128 != (months, days,nanos) + (months, days,nanos).

The consequence of defining this type numerically here is that arithmetic kernels will accept this type, but they will yield a semantically incorrect result (e.g. i128 + i128 to sum two intervals of 1 month each).

To Reproduce
Do a numerical operation on two arrays of MonthDayNano type (for example add or subtract them). The arithmetic will be performed directly on the i128 representation rather than field by field

Expected behavior
The intervals should be calculated field by field; So for example to add two MonthDayNano fields, the kernels should add the nanoseconds, days and months separately

Additional context

@houqp
Copy link
Member

houqp commented Dec 24, 2021

It might be better to disallow arithmetic for this type because number of days in a month and number of nanos in a day is different depending on the reference point of time you are in. So there is no perfect way to handle it. Compute engines can choose their own tradeoffs and implement arithmetic and ordering downstream.

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 bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants