(array: &Int64Array, target_type: &ArrowType)
| 333 | } |
| 334 | |
| 335 | fn coerce_i64(array: &Int64Array, target_type: &ArrowType) -> Result<ArrayRef> { |
| 336 | Ok(match target_type { |
| 337 | ArrowType::Int64 => Arc::new(array.clone()) as _, |
| 338 | // follow C++ implementation and use overflow/reinterpret cast from i64 to u64 which will map |
| 339 | // `i64::MIN..0` to `(i64::MAX as u64)..u64::MAX` |
| 340 | ArrowType::UInt64 => Arc::new(UInt64Array::new( |
| 341 | array.values().inner().clone().into(), |
| 342 | array.nulls().cloned(), |
| 343 | )) as ArrayRef, |
| 344 | ArrowType::Date64 => Arc::new(array.reinterpret_cast::<Date64Type>()) as _, |
| 345 | ArrowType::Time64(TimeUnit::Microsecond) => { |
| 346 | Arc::new(array.reinterpret_cast::<Time64MicrosecondType>()) as _ |
| 347 | } |
| 348 | ArrowType::Time64(TimeUnit::Nanosecond) => { |
| 349 | Arc::new(array.reinterpret_cast::<Time64NanosecondType>()) as _ |
| 350 | } |
| 351 | ArrowType::Duration(unit) => match unit { |
| 352 | TimeUnit::Second => Arc::new(array.reinterpret_cast::<DurationSecondType>()) as _, |
| 353 | TimeUnit::Millisecond => { |
| 354 | Arc::new(array.reinterpret_cast::<DurationMillisecondType>()) as _ |
| 355 | } |
| 356 | TimeUnit::Microsecond => { |
| 357 | Arc::new(array.reinterpret_cast::<DurationMicrosecondType>()) as _ |
| 358 | } |
| 359 | TimeUnit::Nanosecond => { |
| 360 | Arc::new(array.reinterpret_cast::<DurationNanosecondType>()) as _ |
| 361 | } |
| 362 | }, |
| 363 | ArrowType::Timestamp(time_unit, timezone) => match time_unit { |
| 364 | TimeUnit::Second => { |
| 365 | let array = array |
| 366 | .reinterpret_cast::<TimestampSecondType>() |
| 367 | .with_timezone_opt(timezone.clone()); |
| 368 | Arc::new(array) as _ |
| 369 | } |
| 370 | TimeUnit::Millisecond => { |
| 371 | let array = array |
| 372 | .reinterpret_cast::<TimestampMillisecondType>() |
| 373 | .with_timezone_opt(timezone.clone()); |
| 374 | Arc::new(array) as _ |
| 375 | } |
| 376 | TimeUnit::Microsecond => { |
| 377 | let array = array |
| 378 | .reinterpret_cast::<TimestampMicrosecondType>() |
| 379 | .with_timezone_opt(timezone.clone()); |
| 380 | Arc::new(array) as _ |
| 381 | } |
| 382 | TimeUnit::Nanosecond => { |
| 383 | let array = array |
| 384 | .reinterpret_cast::<TimestampNanosecondType>() |
| 385 | .with_timezone_opt(timezone.clone()); |
| 386 | Arc::new(array) as _ |
| 387 | } |
| 388 | }, |
| 389 | ArrowType::Decimal64(p, s) => { |
| 390 | let array = array |
| 391 | .reinterpret_cast::<Decimal64Type>() |
| 392 | .with_precision_and_scale(*p, *s)?; |
no test coverage detected