-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Closed
Labels
Description
Describe the bug
Panic in pretty_format function when displaying DurationSecondsArray with i64::MIN / i64::MAX
To Reproduce
use std::sync::Arc;
use arrow::array::{ArrayRef, DurationSecondArray};
use arrow::util::pretty::pretty_format_columns;
fn main() {
// The following code panics
let array = DurationSecondArray::from(
vec![Some(i64::MIN), Some(i64::MAX), None, Some(4)],
);
let array: ArrayRef = Arc::new(array);
// Panics:
// arrow-array-55.1.0/src/temporal_conversions.rs:221:30:
// called `Option::unwrap()` on a `None` value
println!("The array is:\n{}", pretty_format_columns("array", &[array]).unwrap());
}Cargo.toml
[package]
name = "rust_playground2"
version = "0.1.0"
edition = "2024"
[dependencies]
arrow = { version ="55.1.0", features=["prettyprint"] }Results in a panic
thread 'main' panicked at /Users/andrewlamb/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/arrow-array-55.1.0/src/temporal_conversions.rs:221:30:
called `Option::unwrap()` on a `None` value
Details
thread 'main' panicked at /Users/andrewlamb/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/arrow-array-55.1.0/src/temporal_conversions.rs:221:30:
called `Option::unwrap()` on a `None` value
stack backtrace:
0: __rustc::rust_begin_unwind
at /rustc/17067e9ac6d7ecb70e50f92c1944e545188d2359/library/std/src/panicking.rs:697:5
1: core::panicking::panic_fmt
at /rustc/17067e9ac6d7ecb70e50f92c1944e545188d2359/library/core/src/panicking.rs:75:14
2: core::panicking::panic
at /rustc/17067e9ac6d7ecb70e50f92c1944e545188d2359/library/core/src/panicking.rs:145:5
3: core::option::unwrap_failed
at /rustc/17067e9ac6d7ecb70e50f92c1944e545188d2359/library/core/src/option.rs:2015:5
4: core::option::Option<T>::unwrap
at /Users/andrewlamb/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/src/rust/library/core/src/option.rs:978:21
5: arrow_array::temporal_conversions::duration_s_to_duration
at /Users/andrewlamb/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/arrow-array-55.1.0/src/temporal_conversions.rs:221:5
6: <&arrow_array::array::primitive_array::PrimitiveArray<arrow_array::types::DurationSecondType> as arrow_cast::display::DisplayIndexState>::write
at /Users/andrewlamb/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/arrow-cast-55.1.0/src/display.rs:605:64
7: <arrow_cast::display::ArrayFormat<F> as arrow_cast::display::DisplayIndex>::write
at /Users/andrewlamb/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/arrow-cast-55.1.0/src/display.rs:409:9
8: <arrow_cast::display::ValueFormatter as core::fmt::Display>::fmt
at /Users/andrewlamb/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/arrow-cast-55.1.0/src/display.rs:207:15
9: <T as alloc::string::SpecToString>::spec_to_string
at /Users/andrewlamb/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/src/rust/library/alloc/src/string.rs:2768:9
10: <T as alloc::string::ToString>::to_string
at /Users/andrewlamb/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/src/rust/library/alloc/src/string.rs:2747:9
11: comfy_table::cell::Cell::new
at /Users/andrewlamb/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/comfy-table-7.1.4/src/cell.rs:29:23
12: arrow_cast::pretty::create_column
at /Users/andrewlamb/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/arrow-cast-55.1.0/src/pretty.rs:203:30
13: arrow_cast::pretty::pretty_format_columns_with_options
at /Users/andrewlamb/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/arrow-cast-55.1.0/src/pretty.rs:126:5
14: arrow_cast::pretty::pretty_format_columns
at /Users/andrewlamb/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/arrow-cast-55.1.0/src/pretty.rs:115:5
15: rust_playground2::main
at ./src/main.rs:12:35
16: core::ops::function::FnOnce::call_once
at /Users/andrewlamb/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/src/rust/library/core/src/ops/function.rs:250:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
Expected behavior
I expect the program to print without panic (perhaps a blank or message about invalid duration)
Additional context
The Arrow format does not seem to impose any numerical limits on the values of a Duration::Second: