Skip to content

Commit

Permalink
apacheGH-37377: [C#] Throw OverflowException on overflow in Timestamp…
Browse files Browse the repository at this point in the history
…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>
  • Loading branch information
DanTm99 authored and etseidl committed Sep 28, 2023
1 parent 513306e commit 8275451
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion csharp/src/Apache.Arrow/Arrays/TimestampArray.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ protected override long ConvertTo(DateTimeOffset value)
switch (DataType.Unit)
{
case TimeUnit.Nanosecond:
return ticks * 100;
return checked(ticks * 100);
case TimeUnit.Microsecond:
return ticks / 10;
case TimeUnit.Millisecond:
Expand Down

0 comments on commit 8275451

Please sign in to comment.