alamb commented on code in PR #4504:
URL: https://github.com/apache/arrow-rs/pull/4504#discussion_r1258816638
##########
arrow-arith/src/numeric.rs:
##########
@@ -606,8 +606,32 @@ fn date_op<T: DateOp>(
use DataType::*;
use IntervalUnit::*;
+ let r_t = r.data_type();
+ match (T::DATA_TYPE, op, r_t) {
+ (Date32, Op::Sub | Op::SubWrapping, Date32) => {
+ let l = l.as_primitive::<Date32Type>();
+ let r = r.as_primitive::<Date32Type>();
+ return Ok(op_ref!(
+ DurationSecondType,
+ l,
+ l_s,
+ r,
+ r_s,
+ ((l as i64) - (r as i64)) * 86400
Review Comment:
The units of `Date32` are "seconds" so I understand why to multiply by
`86400`
For clarity I suggest: naming `86400` something like "SECONDS_IN_A_YEAR" via
a `const`
And is the reason to cast to i64 because that is the native type of
`DurationSecondType`?
--
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]