diff --git a/arrow-string/src/length.rs b/arrow-string/src/length.rs index aba75fed856f..2fa399a56db7 100644 --- a/arrow-string/src/length.rs +++ b/arrow-string/src/length.rs @@ -138,10 +138,15 @@ pub fn bit_length(array: &dyn Array) -> Result { let list = array.as_string::(); Ok(bit_length_impl::(list.offsets(), list.nulls())) } - DataType::Utf8View => Ok(Arc::new(Int32Array::from_unary( - array.as_string_view(), - |x| i32::mul_wrapping(x.bytes().len() as i32, 8), - ))), + DataType::Utf8View => { + let list = array.as_string_view(); + let values = list + .views() + .iter() + .map(|view| (*view as i32).wrapping_mul(8)) + .collect(); + Ok(Arc::new(Int32Array::new(values, array.nulls().cloned()))) + } DataType::Binary => { let list = array.as_binary::(); Ok(bit_length_impl::(list.offsets(), list.nulls()))