Skip to content

Commit

Permalink
GH-37377: [C#] Throw OverflowException on overflow in TimestampArray.…
Browse files Browse the repository at this point in the history
…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 <[email protected]>
Signed-off-by: Weston Pace <[email protected]>
  • Loading branch information
DanTm99 authored Sep 27, 2023
1 parent 7dc9f69 commit 2864870
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 2864870

Please sign in to comment.