alamb opened a new issue, #3962:
URL: https://github.com/apache/arrow-rs/issues/3962

   **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:
   
   ```rust
   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**
   <!--
   A clear and concise description of any alternative solutions or features 
you've considered.
   -->
   
   **Additional context**
   <!--
   Add any other context or screenshots about the feature request here.
   -->
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to