Commit 1a61a59
authored
fix date_bin overflows subtracting extreme nanosecond timestamp origin (#22251)
## Which issue does this PR close?
- Closes #22210
## Rationale for this change
`date_bin` could overflow when subtracting extreme nanosecond
timestamps, which could trigger a panic. This fix makes that path return
an error instead, so the query safely returns `NULL` rather than
crashing.
## What changes are included in this PR?
- In date_bin.rs, the nanosecond path now uses `checked_sub` instead of
direct subtraction, and returns an `ArrowError::InvalidArgumentError` on
overflow.
- In date_bin_errors.slt, a regression test was added for an extreme
nanosecond timestamp case to verify that overflow returns `NULL` instead
of panicking.
## Are these changes tested?
- Yes. The new sqllogictest covers the regression scenario and verifies
that extreme nanosecond timestamp input returns `NULL`.
## Are there any user-facing changes?
- Yes. `date_bin` is now more robust for extreme nanosecond timestamp
inputs and will return `NULL` instead of panicking.1 parent 7e90f52 commit 1a61a59
2 files changed
Lines changed: 15 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
321 | 321 | | |
322 | 322 | | |
323 | 323 | | |
324 | | - | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
325 | 329 | | |
326 | 330 | | |
327 | 331 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
60 | 70 | | |
0 commit comments