-
Couldn't load subscription status.
- Fork 1k
Closed
Labels
Description
Describe the bug
It looks like date_part using an interval will return the whole interval instead of taking out the part.
To Reproduce
use arrow::array::{Int32Array, IntervalMonthDayNanoArray, TimestampSecondArray};
use arrow::compute::{date_part, DatePart};
use arrow::datatypes::IntervalMonthDayNano;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let array = TimestampSecondArray::from(vec![305]); // 5 minutes, 5 seconds
let result = date_part(&array, DatePart::Second)?
.as_any()
.downcast_ref::<Int32Array>()
.unwrap()
.iter()
.collect::<Vec<Option<i32>>>();
assert_eq!(result, &[Some(5)]); // As expected
let array = IntervalMonthDayNanoArray::from(vec![
IntervalMonthDayNano::new(0, 0, 305 * 1_000_000_000), // 0 months, 0 days, 305 seconds
]);
let res: Vec<Option<i32>> = date_part(&array, DatePart::Second)?
.as_any()
.downcast_ref::<Int32Array>()
.unwrap()
.iter()
.collect::<Vec<Option<i32>>>();
assert_eq!(res, &[Some(5)]); // Fails, result is 305
Ok(())
}Expected behavior
date_part returns the requested part.
Additional context