Coerce the parquet physical type array to the target type This should match the logic in schema::primitive::apply_hint
(array: ArrayRef, target_type: &ArrowType)
| 225 | /// |
| 226 | /// This should match the logic in schema::primitive::apply_hint |
| 227 | fn coerce_array(array: ArrayRef, target_type: &ArrowType) -> Result<ArrayRef> { |
| 228 | if let ArrowType::Dictionary(key_type, value_type) = target_type { |
| 229 | let dictionary = pack_dictionary(key_type, array.as_ref())?; |
| 230 | let any_dictionary = dictionary.as_any_dictionary(); |
| 231 | |
| 232 | let coerced_values = |
| 233 | coerce_array(Arc::clone(any_dictionary.values()), value_type.as_ref())?; |
| 234 | |
| 235 | return Ok(any_dictionary.with_values(coerced_values)); |
| 236 | } |
| 237 | |
| 238 | match array.data_type() { |
| 239 | ArrowType::Int32 => coerce_i32(array.as_primitive(), target_type), |
| 240 | ArrowType::Int64 => coerce_i64(array.as_primitive(), target_type), |
| 241 | ArrowType::Boolean | ArrowType::Float32 | ArrowType::Float64 => Ok(array), |
| 242 | _ => unreachable!("Cannot coerce array of type {}", array.data_type()), |
| 243 | } |
| 244 | } |
| 245 | |
| 246 | fn coerce_i32(array: &Int32Array, target_type: &ArrowType) -> Result<ArrayRef> { |
| 247 | Ok(match target_type { |
no test coverage detected