diff --git a/arrow-cast/src/cast/dictionary.rs b/arrow-cast/src/cast/dictionary.rs index ec0ab346f997..0a4d75c75ee0 100644 --- a/arrow-cast/src/cast/dictionary.rs +++ b/arrow-cast/src/cast/dictionary.rs @@ -325,6 +325,13 @@ pub(crate) fn cast_to_dictionary( } pack_byte_to_dictionary::>(array, cast_options) } + FixedSizeBinary(i32) => { + // If the input is a view type, we can avoid casting (thus copying) the data + if array.data_type() == &DataType::FixedSizeBinary(i32) { + return binary_view_to_dictionary::(array); + } + pack_byte_to_dictionary::>(array, cast_options) + } _ => Err(ArrowError::CastError(format!( "Unsupported output type for dictionary packing: {dict_value_type:?}" ))),