(
array: &dyn Array,
cast_options: &CastOptions,
)
| 347 | } |
| 348 | |
| 349 | pub(crate) fn cast_binary_to_string<O: OffsetSizeTrait>( |
| 350 | array: &dyn Array, |
| 351 | cast_options: &CastOptions, |
| 352 | ) -> Result<ArrayRef, ArrowError> { |
| 353 | let array = array |
| 354 | .as_any() |
| 355 | .downcast_ref::<GenericByteArray<GenericBinaryType<O>>>() |
| 356 | .unwrap(); |
| 357 | |
| 358 | match GenericStringArray::<O>::try_from_binary(array.clone()) { |
| 359 | Ok(a) => Ok(Arc::new(a)), |
| 360 | Err(e) => match cast_options.safe { |
| 361 | true => { |
| 362 | // Fallback to slow method to convert invalid sequences to nulls |
| 363 | let mut builder = |
| 364 | GenericStringBuilder::<O>::with_capacity(array.len(), array.value_data().len()); |
| 365 | |
| 366 | extend_valid_utf8(&mut builder, array.iter()); |
| 367 | Ok(Arc::new(builder.finish())) |
| 368 | } |
| 369 | false => Err(e), |
| 370 | }, |
| 371 | } |
| 372 | } |
| 373 | |
| 374 | pub(crate) fn cast_binary_view_to_string_view( |
| 375 | array: &dyn Array, |
nothing calls this directly
no test coverage detected