Repository navigation
Commit 06ab323
committed
GH-1293: Use floor division when splitting epoch millis into day and time
DateTimeUtils.getTimestampValue split epoch millis into an epoch day and a
time-of-day remainder using `/` and `%`, which truncate toward zero. Only the
remainder half compensated for negative input, so for any negative value that
was not an exact multiple of a day the two halves described different days and
the returned timestamp was one day later than the instant given. This is
reachable from ArrowFlightJdbcDateVectorAccessor.getDate(Calendar), where the
calendar offset shifts a day-aligned date value off that alignment, making
every pre-1970 date come back a day late.
Use Math.floorDiv and Math.floorMod for both halves, which keeps the day and
the remainder on the same day and makes the manual negative adjustment
redundant. Positive input is unaffected, since both functions agree with `/`
and `%` there.
Closes #1293.1 parent 91b4a2c commit 06ab323
2 files changed
Lines changed: 16 additions & 8 deletions
File tree
- flight/flight-sql-jdbc-core/src
- main/java/org/apache/arrow/driver/jdbc/utils
- test/java/org/apache/arrow/driver/jdbc/utils
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
55 | 55 | | |
56 | 56 | | |
57 | 57 | | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
| 58 | + | |
| 59 | + | |
64 | 60 | | |
65 | 61 | | |
66 | | - | |
67 | | - | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
68 | 65 | | |
69 | 66 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
95 | 95 | | |
96 | 96 | | |
97 | 97 | | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
98 | 109 | | |
0 commit comments