Force downcast of an [`Array`], such as an [`ArrayRef`], to [`PrimitiveArray `], panic'ing on failure. # Example ``` # use std::sync::Arc; # use arrow_array::{ArrayRef, Int32Array}; # use arrow_array::cast::as_primitive_array; # use arrow_array::types::Int32Type; let arr: ArrayRef = Arc::new(Int32Array::from(vec![Some(1)])); // Downcast an `ArrayRef` to Int32Array / PrimitiveArray : le
(arr: &dyn Array)
| 502 | /// .unwrap(); |
| 503 | /// ``` |
| 504 | pub fn as_primitive_array<T>(arr: &dyn Array) -> &PrimitiveArray<T> |
| 505 | where |
| 506 | T: ArrowPrimitiveType, |
| 507 | { |
| 508 | arr.as_any() |
| 509 | .downcast_ref::<PrimitiveArray<T>>() |
| 510 | .expect("Unable to downcast to primitive array") |
| 511 | } |
| 512 | |
| 513 | #[macro_export] |
| 514 | #[doc(hidden)] |
no test coverage detected