Macro downcast_dictionary_array
macro_rules! downcast_dictionary_array {
($values:ident => $e:expr, $($p:pat => $fallback:expr $(,)*)*) => { ... };
($values:ident => $e:block $($p:pat => $fallback:expr $(,)*)*) => { ... };
}
Expand description
Downcast an Array
to a DictionaryArray
based on its DataType
, accepts
a number of subsequent patterns to match the data type
fn print_strings(array: &dyn Array) {
downcast_dictionary_array!(
array => match array.values().data_type() {
DataType::Utf8 => {
for v in array.downcast_dict::<StringArray>().unwrap() {
println!("{:?}", v);
}
}
t => println!("Unsupported dictionary value type {}", t),
},
DataType::Utf8 => {
for v in as_string_array(array) {
println!("{:?}", v);
}
}
t => println!("Unsupported datatype {}", t)
)
}