@@ -134,7 +134,8 @@ struct CastFunctor<
134134 const auto & in_type = checked_cast<const I&>(*batch[0 ].type ());
135135 const auto & out_type = checked_cast<const O&>(*output->type );
136136
137- DCHECK_NE (in_type.unit (), out_type.unit ()) << " Do not cast equal types" ;
137+ // The units may be equal if the time zones are different. We might go to
138+ // lengths to make this zero copy in the future but we leave it for now
138139
139140 auto conversion = util::kTimestampConversionTable [static_cast <int >(in_type.unit ())]
140141 [static_cast <int >(out_type.unit ())];
@@ -344,10 +345,7 @@ std::shared_ptr<CastFunction> GetDurationCast() {
344345 auto nanos = duration (TimeUnit::NANO);
345346
346347 // Same integer representation
347- AddZeroCopyCast (/* in_type=*/ int64 (), /* out_type=*/ seconds, func.get ());
348- AddZeroCopyCast (int64 (), millis, func.get ());
349- AddZeroCopyCast (int64 (), micros, func.get ());
350- AddZeroCopyCast (int64 (), nanos, func.get ());
348+ AddZeroCopyCast (/* in_type=*/ int64 (), kOutputTargetType , func.get ());
351349
352350 // Between durations
353351 AddCrossUnitCast<DurationType>(func.get ());
@@ -359,12 +357,8 @@ std::shared_ptr<CastFunction> GetTime32Cast() {
359357 auto func = std::make_shared<CastFunction>(" cast_time32" , Type::TIME32);
360358 AddCommonCasts<Date32Type>(kOutputTargetType , func.get ());
361359
362- auto seconds = time32 (TimeUnit::SECOND);
363- auto millis = time32 (TimeUnit::MILLI);
364-
365360 // Zero copy when the unit is the same or same integer representation
366- AddZeroCopyCast (int32 (), seconds, func.get ());
367- AddZeroCopyCast (int32 (), millis, func.get ());
361+ AddZeroCopyCast (/* in_type=*/ int32 (), kOutputTargetType , func.get ());
368362
369363 // time64 -> time32
370364 AddSimpleCast<Time64Type, Time32Type>(InputType (Type::TIME64), kOutputTargetType ,
@@ -380,12 +374,8 @@ std::shared_ptr<CastFunction> GetTime64Cast() {
380374 auto func = std::make_shared<CastFunction>(" cast_time64" , Type::TIME64);
381375 AddCommonCasts<Time64Type>(kOutputTargetType , func.get ());
382376
383- auto micros = time64 (TimeUnit::MICRO);
384- auto nanos = time64 (TimeUnit::NANO);
385-
386377 // Zero copy when the unit is the same or same integer representation
387- AddZeroCopyCast (int64 (), micros, func.get ());
388- AddZeroCopyCast (int64 (), nanos, func.get ());
378+ AddZeroCopyCast (/* in_type=*/ int64 (), kOutputTargetType , func.get ());
389379
390380 // time32 -> time64
391381 AddSimpleCast<Time32Type, Time64Type>(InputType (Type::TIME32), kOutputTargetType ,
@@ -402,11 +392,7 @@ std::shared_ptr<CastFunction> GetTimestampCast() {
402392 AddCommonCasts<TimestampType>(kOutputTargetType , func.get ());
403393
404394 // Same integer representation
405- AddZeroCopyCast (/* in_type=*/ int64 (), /* out_type=*/ timestamp (TimeUnit::SECOND),
406- func.get ());
407- AddZeroCopyCast (int64 (), timestamp (TimeUnit::MILLI), func.get ());
408- AddZeroCopyCast (int64 (), timestamp (TimeUnit::MICRO), func.get ());
409- AddZeroCopyCast (int64 (), timestamp (TimeUnit::NANO), func.get ());
395+ AddZeroCopyCast (/* in_type=*/ int64 (), kOutputTargetType , func.get ());
410396
411397 // From date types
412398 // TODO: ARROW-8876, these casts are not implemented
0 commit comments