-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Closed
Labels
arrowChanges to the arrow crateChanges to the arrow crateenhancementAny new improvement worthy of a entry in the changelogAny new improvement worthy of a entry in the changeloggood first issueGood for newcomersGood for newcomers
Description
Is your feature request related to a problem or challenge? Please describe what you are trying to do.
One may like to find out "2 days ago" by computing a date - Interval.
while adding Date to intervals is supported, subtracting is not
Describe the solution you'd like
I would like subtract_dyn not to panic:
fn add_interval_date() {
let arr = Arc::new(Date32Array::from(vec![
1_000_000,
])) as ArrayRef;
// Would like to add and subtract intervals:
// would like to add and substract 1 day
let interval_array = Arc::new(IntervalDayTimeArray::from(vec![
Some(IntervalDayTimeType::make_value(0, 1)),
])) as ArrayRef;
// input:
// +------------+
// | input |
// +------------+
// | 4707-11-29 |
// +------------+
println!(
"input:\n{}",
pretty_format_columns("input", &[arr.clone()]).unwrap()
);
// interval:
// +-------------------------------------------------+
// | interval |
// +-------------------------------------------------+
// | 0 years 0 mons 0 days 0 hours 0 mins 0.001 secs |
// +-------------------------------------------------+
println!(
"interval:\n{}",
pretty_format_columns("interval", &[interval_array.clone()]).unwrap()
);
// add:
// +------------+
// | out |
// +------------+
// | 4707-11-29 |
// +------------+
let new_arr = add_dyn(&arr, interval_array.as_ref()).unwrap();
println!(
"add:\n{}",
pretty_format_columns("out", &[new_arr]).unwrap()
);
// panics"
// thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: CastError("Unsupported data type Date32, Interval(DayTime)")', src/main.rs:154:63
let new_arr = subtract_dyn(&arr, interval_array.as_ref()).unwrap();
println!(
"sub:\n{}",
pretty_format_columns("out", &[new_arr]).unwrap()
);
}Describe alternatives you've considered
Additional context
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
arrowChanges to the arrow crateChanges to the arrow crateenhancementAny new improvement worthy of a entry in the changelogAny new improvement worthy of a entry in the changeloggood first issueGood for newcomersGood for newcomers