MCPcopy Create free account
hub / github.com/apache/arrow-rs / cast_binary_to_string

Function cast_binary_to_string

arrow-cast/src/cast/string.rs:349–372  ·  view source on GitHub ↗
(
    array: &dyn Array,
    cast_options: &CastOptions,
)

Source from the content-addressed store, hash-verified

347}
348
349pub(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
374pub(crate) fn cast_binary_view_to_string_view(
375 array: &dyn Array,

Callers

nothing calls this directly

Calls 7

extend_valid_utf8Function · 0.85
as_anyMethod · 0.45
cloneMethod · 0.45
lenMethod · 0.45
value_dataMethod · 0.45
iterMethod · 0.45
finishMethod · 0.45

Tested by

no test coverage detected