Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions arrow-cast/src/cast/dictionary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,19 @@ pub(crate) fn cast_to_dictionary<K: ArrowDictionaryKeyType>(
}
pack_byte_to_dictionary::<K, GenericStringType<i64>>(array, cast_options)
}
Utf8View => {
let base_value_type = match array.data_type() {
DataType::LargeUtf8 | DataType::Utf8View => DataType::LargeUtf8,
_ => DataType::Utf8,
};

let dict_base = cast_to_dictionary::<K>(array, &base_value_type, cast_options)?;
dictionary_cast::<K>(
dict_base.as_ref(),
&DataType::Dictionary(Box::new(K::DATA_TYPE), Box::new(DataType::Utf8View)),
cast_options,
)
}
Binary => {
// If the input is a view type, we can avoid casting (thus copying) the data
if array.data_type() == &DataType::BinaryView {
Expand All @@ -286,6 +299,19 @@ pub(crate) fn cast_to_dictionary<K: ArrowDictionaryKeyType>(
}
pack_byte_to_dictionary::<K, GenericBinaryType<i64>>(array, cast_options)
}
BinaryView => {
let base_value_type = match array.data_type() {
DataType::LargeBinary | DataType::BinaryView => DataType::LargeBinary,
_ => DataType::Binary,
};

let dict_base = cast_to_dictionary::<K>(array, &base_value_type, cast_options)?;
dictionary_cast::<K>(
dict_base.as_ref(),
&DataType::Dictionary(Box::new(K::DATA_TYPE), Box::new(DataType::BinaryView)),
cast_options,
)
}
FixedSizeBinary(byte_size) => {
pack_byte_to_fixed_size_dictionary::<K>(array, cast_options, byte_size)
}
Expand Down
Loading