alamb opened a new issue, #3512:
URL: https://github.com/apache/arrow-rs/issues/3512
**Describe the bug**
When a string such as `'1677-06-14T07:29:01.256'` is casted to a timestamp
(via `string_to_timestamp_nanos`) it panics in debug builds and gives a wonky
answer in release builds.
**To Reproduce**
Run this test in `arrow-cast/src/display.rs`
```rust
#[test]
fn string_to_timestamp_old() {
assert_eq!(
123,
parse_timestamp("1677-06-14T07:29:01.256").unwrap()
);
}
```
```
failures:
---- parse::tests::string_to_timestamp_old stdout ----
thread 'parse::tests::string_to_timestamp_old' panicked at 'attempt to
multiply with overflow',
/Users/alamb/.cargo/registry/src/github.com-1ecc6299db9ec823/chrono-0.4.23/src/naive/datetime/mod.rs:426:21
stack backtrace:
0: rust_begin_unwind
at
/rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/std/src/panicking.rs:575:5
1: core::panicking::panic_fmt
at
/rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/core/src/panicking.rs:65:14
2: core::panicking::panic
at
/rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/core/src/panicking.rs:115:5
3: chrono::naive::datetime::NaiveDateTime::timestamp_nanos
at
/Users/alamb/.cargo/registry/src/github.com-1ecc6299db9ec823/chrono-0.4.23/src/naive/datetime/mod.rs:426:21
4: arrow_cast::parse::string_to_timestamp_nanos
at ./src/parse.rs:102:19
5: arrow_cast::parse::tests::parse_timestamp
at ./src/parse.rs:544:22
6: arrow_cast::parse::tests::string_to_timestamp_old
at ./src/parse.rs:471:13
7: arrow_cast::parse::tests::string_to_timestamp_old::{{closure}}
at ./src/parse.rs:468:5
8: core::ops::function::FnOnce::call_once
at
/rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/core/src/ops/function.rs:251:5
9: core::ops::function::FnOnce::call_once
at
/rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/core/src/ops/function.rs:251:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose
backtrace.
failures:
parse::tests::string_to_timestamp_old
```
**Expected behavior**
It should not panic
**Additional context**
Found in datafusion https://github.com/apache/arrow-datafusion/issues/4875
by @DDtKey
The actual panic is in chrono, it appears to be this line
https://github.com/apache/arrow-rs/blob/55c87c114443739ed73ebc28d0ba53bf875ecd9a/arrow-cast/src/parse.rs#L99-L103
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]