Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

An error occurs in epoch_to_timestamp: multiply with overflow. #113

Closed
yjhong79 opened this issue Nov 21, 2024 · 2 comments · Fixed by #114
Closed

An error occurs in epoch_to_timestamp: multiply with overflow. #113

yjhong79 opened this issue Nov 21, 2024 · 2 comments · Fixed by #114

Comments

@yjhong79
Copy link

The epoch_to_timestamp function can handle time units from seconds to nanoseconds.

As explained in the documentation below, the range for nanoseconds is between 1677-09-21T00:12:43.145224192 and 2262-04-11T23:47:16.854775807:
https://docs.rs/chrono/latest/chrono/struct.DateTime.html#method.timestamp_nanos_opt

Inside the function, all values are forcibly converted to nanoseconds for processing. If a value is input that cannot be converted to nanoseconds (i.e., the computed value exceeds the i64 range), a multiply with overflow error occurs in debug mode. In release mode, this error is ignored, leading to incorrect calculations due to overflow.

Therefore, it seems necessary to handle inputs differently depending on their scale.

Below is test code to reproduce the error:

let overflow_time = DateTime::parse_from_rfc3339("1600-06-18T23:12:44.000Z").unwrap();
let time = epoch_to_timestamp::<1_000_000>(overflow_time.timestamp_micros());
println!("{:?}", time);  

// Release output:
// Timestamp { year: 1715, month: 11, day: 28, hour: 23, minute: 38, second: 10, fraction: 290448384 }
@pacman82
Copy link
Owner

Hello @yjhong79 ,

thanks for reporting the bug!

Yeah indeed, I think you are correct. Luckily so far no one seems to work in a domain which requires dating historical artifacts with nanoseconds precision 😁 .

I'll handle it, but I am pretty swamped until the end of the month.

Best, Markus

@pacman82
Copy link
Owner

Hello @yjhong79 ,

thanks again for reporting the bug. arrow-odbc 13.0.2 is released with a fix.

Best, Markus

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants