tustvold commented on code in PR #4182:
URL: https://github.com/apache/arrow-rs/pull/4182#discussion_r1213012070
##########
arrow-cast/src/cast.rs:
##########
@@ -409,6 +413,125 @@ where
}
}
+/// Cast the array from interval year month to month day nano
+fn cast_interval_year_month_to_interval_month_day_nano(
+ array: &dyn Array,
+ cast_options: &CastOptions,
+) -> Result<ArrayRef, ArrowError> {
+ let array = array.as_primitive::<IntervalYearMonthType>();
+
+ if cast_options.safe {
+ Ok(Arc::new(array.unary_opt::<_, IntervalMonthDayNanoType>(
+ |v| {
+ let months = IntervalYearMonthType::to_months(v);
+ Some(IntervalMonthDayNanoType::make_value(months, 0, 0))
+ },
+ )))
+ } else {
+ Ok(Arc::new(
+ array.try_unary::<_, IntervalMonthDayNanoType, ArrowError>(|v| {
Review Comment:
If the method is infallible you can just use `unary` without needing to use
either `unary_opt` or `try_unary`
--
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]