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

[C#] TimestampArray.ConvertTo() returns erroneous value for large ticks when returning nanoseconds #37377

Closed
DanTm99 opened this issue Aug 25, 2023 · 0 comments · Fixed by #37388
Assignees
Milestone

Comments

@DanTm99
Copy link
Contributor

DanTm99 commented Aug 25, 2023

Describe the bug, including details regarding any error messages, version, and platform.

TimestampArray.ConvertTo() can return an erroneous value when ticks is large (both positive and negative) and DataType.Unit is Nanosecond, due to an overflow silently occurring when multiplying ticks.

This could be replaced with an explicit error, by returning an OverflowException on overflow. C# doesn't check for overflows by default, but this can be enabled by performing the calculation in a checked operation.

However, this could lead to a breaking change, as it would require the explicit handling of errors when overflows occur when building a timestamp array. But this would mean all occurrences of this error will be explicit, instead of silently producing bad data.

Component(s)

C#

DanTm99 added a commit to DanTm99/arrow that referenced this issue Aug 25, 2023
westonpace pushed a commit that referenced this issue Sep 27, 2023
…ConvertTo() (#37388)

Throw `OverflowException` on overflow in `TimestampArray.ConvertTo()` when `DataType.Unit` is `Nanosecond` and `ticks` is large, instead of silently overflowing and returning the wrong value.
* Closes: #37377

Authored-by: Danyaal Khan <danyaal99@hotmail.co.uk>
Signed-off-by: Weston Pace <weston.pace@gmail.com>
@westonpace westonpace added this to the 14.0.0 milestone Sep 27, 2023
etseidl pushed a commit to etseidl/arrow that referenced this issue Sep 28, 2023
…Array.ConvertTo() (apache#37388)

Throw `OverflowException` on overflow in `TimestampArray.ConvertTo()` when `DataType.Unit` is `Nanosecond` and `ticks` is large, instead of silently overflowing and returning the wrong value.
* Closes: apache#37377

Authored-by: Danyaal Khan <danyaal99@hotmail.co.uk>
Signed-off-by: Weston Pace <weston.pace@gmail.com>
JerAguilon pushed a commit to JerAguilon/arrow that referenced this issue Oct 23, 2023
…Array.ConvertTo() (apache#37388)

Throw `OverflowException` on overflow in `TimestampArray.ConvertTo()` when `DataType.Unit` is `Nanosecond` and `ticks` is large, instead of silently overflowing and returning the wrong value.
* Closes: apache#37377

Authored-by: Danyaal Khan <danyaal99@hotmail.co.uk>
Signed-off-by: Weston Pace <weston.pace@gmail.com>
loicalleyne pushed a commit to loicalleyne/arrow that referenced this issue Nov 13, 2023
…Array.ConvertTo() (apache#37388)

Throw `OverflowException` on overflow in `TimestampArray.ConvertTo()` when `DataType.Unit` is `Nanosecond` and `ticks` is large, instead of silently overflowing and returning the wrong value.
* Closes: apache#37377

Authored-by: Danyaal Khan <danyaal99@hotmail.co.uk>
Signed-off-by: Weston Pace <weston.pace@gmail.com>
dgreiss pushed a commit to dgreiss/arrow that referenced this issue Feb 19, 2024
…Array.ConvertTo() (apache#37388)

Throw `OverflowException` on overflow in `TimestampArray.ConvertTo()` when `DataType.Unit` is `Nanosecond` and `ticks` is large, instead of silently overflowing and returning the wrong value.
* Closes: apache#37377

Authored-by: Danyaal Khan <danyaal99@hotmail.co.uk>
Signed-off-by: Weston Pace <weston.pace@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants