alamb commented on code in PR #2998: URL: https://github.com/apache/arrow-rs/pull/2998#discussion_r1014072211
########## arrow-cast/src/cast.rs: ########## @@ -302,30 +293,31 @@ pub fn can_cast_types(from_type: &DataType, to_type: &DataType) -> bool { /// * To or from `StructArray` /// * List to primitive /// * Interval and duration -pub fn cast(array: &ArrayRef, to_type: &DataType) -> Result<ArrayRef> { +pub fn cast(array: &ArrayRef, to_type: &DataType) -> Result<ArrayRef, ArrowError> { cast_with_options(array, to_type, &DEFAULT_CAST_OPTIONS) } -fn cast_integer_to_decimal128<T: ArrowNumericType>( +fn cast_integer_to_decimal128<T: ArrowPrimitiveType>( Review Comment: is there a reason to also change this from `ArrowNumericType` to `ArrowPrimitiveType`? Seems fine as all ArrowNumericTypes` are also `ArrowPrimtiveTypes` https://docs.rs/arrow/latest/arrow/datatypes/trait.ArrowNumericType.html ########## arrow-cast/src/display.rs: ########## @@ -533,13 +529,23 @@ fn dict_array_value_to_string<K: ArrowPrimitiveType>( return Ok(String::from("")); } - let dict_index = keys_array.value(row).to_usize().ok_or_else(|| { - ArrowError::InvalidArgumentError(format!( - "Can not convert value {:?} at index {:?} to usize for string conversion.", - keys_array.value(row), - row - )) - })?; - + let dict_index = keys_array.value(row).as_usize(); array_value_to_string(dict_array.values(), dict_index) } + +/// Converts numeric type to a `String` +pub fn lexical_to_string<N: lexical_core::ToLexical>(n: N) -> String { Review Comment: was just moved -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: github-unsubscr...@arrow.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org