bkietz commented on code in PR #6906:
URL: https://github.com/apache/arrow-rs/pull/6906#discussion_r1901999160


##########
arrow-arith/src/numeric.rs:
##########
@@ -550,6 +568,21 @@ date!(Date64Type);
 trait IntervalOp: ArrowPrimitiveType {
     fn add(left: Self::Native, right: Self::Native) -> Result<Self::Native, 
ArrowError>;
     fn sub(left: Self::Native, right: Self::Native) -> Result<Self::Native, 
ArrowError>;
+    fn mul_int(left: Self::Native, right: i32) -> Result<Self::Native, 
ArrowError>;
+    fn mul_float(left: Self::Native, right: f64) -> Result<Self::Native, 
ArrowError>;
+    fn div_int(left: Self::Native, right: i32) -> Result<Self::Native, 
ArrowError>;
+    fn div_float(left: Self::Native, right: f64) -> Result<Self::Native, 
ArrowError>;

Review Comment:
   @felipecrv
   
   > @bkietz what are your thoughts on multiplication and division of interval 
types?
   
   My contention is that (as noted above) intervals don't really map to a 
duration; they map to a pair of timestamps or dates. Indeed, when considered in 
isolation from any associated start or end date column, the only interpretation 
we have left for an interval column is in terms of its (flawed) conversion to 
duration. Therefore, the only interactions which should be supported on 
intervals is arithmetic with dates and timestamps:
   
   ```
   YearMonthInterval +/- Date32 -> Date32
   DayTimeInterval +/- Date64 -> Date64
   MonthDayNanoInterval +/- TimestampNS -> TimestampNS
   ...
   ```
   
   From these and an appropriate start or end date column, we can make the 
correct conversion to duration and do well defined multiplication and division.



-- 
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