@@ -228,6 +228,20 @@ pub fn can_cast_types(from_type: &DataType, to_type: &DataType) -> bool {
228
228
IntervalUnit :: DayTime => true ,
229
229
IntervalUnit :: MonthDayNano => false , // Native type is i128
230
230
}
231
+ } ,
232
+ ( Int32 , Interval ( to_type) ) => {
233
+ match to_type{
234
+ IntervalUnit :: YearMonth => true ,
235
+ IntervalUnit :: DayTime => false ,
236
+ IntervalUnit :: MonthDayNano => false ,
237
+ }
238
+ } ,
239
+ ( Int64 , Interval ( to_type) ) => {
240
+ match to_type{
241
+ IntervalUnit :: YearMonth => false ,
242
+ IntervalUnit :: DayTime => true ,
243
+ IntervalUnit :: MonthDayNano => false ,
244
+ }
231
245
}
232
246
( _, _) => false ,
233
247
}
@@ -1131,6 +1145,24 @@ pub fn cast_with_options(
1131
1145
from_type, to_type,
1132
1146
) ) ) ,
1133
1147
} ,
1148
+ ( Int32 , Interval ( to_type) ) => match to_type {
1149
+ IntervalUnit :: YearMonth => {
1150
+ cast_array_data :: < IntervalYearMonthType > ( array, Interval ( to_type. clone ( ) ) )
1151
+ }
1152
+ _ => Err ( ArrowError :: CastError ( format ! (
1153
+ "Casting from {:?} to {:?} not supported" ,
1154
+ from_type, to_type,
1155
+ ) ) ) ,
1156
+ } ,
1157
+ ( Int64 , Interval ( to_type) ) => match to_type {
1158
+ IntervalUnit :: DayTime => {
1159
+ cast_array_data :: < IntervalDayTimeType > ( array, Interval ( to_type. clone ( ) ) )
1160
+ }
1161
+ _ => Err ( ArrowError :: CastError ( format ! (
1162
+ "Casting from {:?} to {:?} not supported" ,
1163
+ from_type, to_type,
1164
+ ) ) ) ,
1165
+ } ,
1134
1166
( _, _) => Err ( ArrowError :: CastError ( format ! (
1135
1167
"Casting from {:?} to {:?} not supported" ,
1136
1168
from_type, to_type,
0 commit comments