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

Incorrect Overflow Casting String to Timestamp #4033

Closed
tustvold opened this issue Apr 7, 2023 · 1 comment · Fixed by #4034
Closed

Incorrect Overflow Casting String to Timestamp #4033

tustvold opened this issue Apr 7, 2023 · 1 comment · Fixed by #4034
Labels
arrow Changes to the arrow crate bug

Comments

@tustvold
Copy link
Contributor

tustvold commented Apr 7, 2023

Describe the bug

When casting strings to timestamps, they are converted to nanoseconds using string_to_timestamp_nanos. This results in erroneous overflow when handling quantities that can't be represented in an i64 as nanoseconds, but can be encoded as a larger timeunit.

To Reproduce

#[test]
fn test_cast_string_to_timestamp_overflow() {
    // let array = TimestampSecondArray::from(vec![chrono::DateTime::MAX_UTC]);
    // let array = cast(&array, &DataType::Utf8).unwrap();

    let array = StringArray::from(vec!["9800-09-08T12:00:00.123456789"]);
    let result = cast(&array, &DataType::Timestamp(TimeUnit::Second, None)).unwrap();
    let result = result.as_primitive::<TimestampSecondType>();
    assert_eq!(result.values(), &[247112596800]);
}

Expected behavior

Additional context

@tustvold
Copy link
Contributor Author

label_issue.py automatically added labels {'arrow'} from #4034

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

Successfully merging a pull request may close this issue.

1 participant