-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Description
Is your feature request related to a problem or challenge? Please describe what you are trying to do.
I am trying to arithmetically create date / time columns. In my case I want to add some duration (7 days) to a Date32 column
Describe the solution you'd like
I would like temporal kernels that allowed operations such as:
TimestampNanosecondArray + Duration --> TimestampNanosecondArray
Date32Array + Duration --> Date32Array
etc.
I would like to be able to do something like
let date_strings = vec![
Some("2020-01-01"),
Some("2020-01-02"),
Some("2020-01-03"),
None,
Some("2020-01-04"),
];
let arr_date32 = arrow::compute::cast(&arr_string, &DataType::Date32).expect("casting to date");
// note there is no such thing as DurationArray at this time
let offset_seconds = DurationArray::from_days(vec![1, 2, 3, 4, 5]);
let arr_date32_offset = compute::kernels::add(arr_date32, offset_seconds)
// expect the output is
// 2021-01-02
// 2021-01-04
// 2021-01-06
// None
// 2021-01-08Describe alternatives you've considered
It might be nice to extend the arithmetic kernels to take Arc<dyn Array> rather than the PrimitiveArray as they do now and do the casting / calling specific implementations directly.
Additional context
Add any other context or screenshots about the feature request here.