alexandreyc commented on code in PR #4546:
URL: https://github.com/apache/arrow-rs/pull/4546#discussion_r1272316901


##########
arrow-array/src/types.rs:
##########
@@ -350,6 +352,59 @@ impl ArrowTimestampType for TimestampNanosecondType {
     }
 }
 
+fn add_year_months<T: ArrowTimestampType>(
+    timestamp: <T as ArrowPrimitiveType>::Native,
+    delta: <IntervalYearMonthType as ArrowPrimitiveType>::Native,
+    tz: Tz,
+) -> Result<<T as ArrowPrimitiveType>::Native, ArrowError> {
+    let months = IntervalYearMonthType::to_months(delta);
+    let res = as_datetime_with_timezone::<T>(timestamp, tz)
+        .ok_or_else(|| ArrowError::ComputeError("Timestamp out of 
range".to_string()))?;
+    let res = shift_months_datetime(res, months)
+        .ok_or_else(|| ArrowError::ComputeError("Timestamp out of 
range".to_string()))?;
+    let res = res.naive_utc();
+    T::make_value(res)
+        .ok_or_else(|| ArrowError::ComputeError("Timestamp out of 
range".to_string()))

Review Comment:
   After the last commits, the error can now be of two kinds: timestamp or 
interval out of range.
   
   I'm not sure if it's really important to be able to distinguish between 
those errors... If not we can definitely return an Option here (though we 
change the API even more).



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