Is your feature request related to a problem or challenge? Please describe what you are trying to do.
As @mbrobbel pointed out in https://github.com/apache/arrow-rs/pull/8408/files#r2378240955:
There are currently two APIs for seeing if a Field has an extension type:
There is no good API to quickly tell if a Field has an extension type. The current way is like
if field.try_extension_type<TheExtensionType>().is_ok() {
// field has extension type
}
Works, but it requires creating an ArrowError if the field is not the requested type, which is slow as it allocates a String
in #8408 I came up with this to avoid the problem, but it is not obvious and somewhat redundant:
// Check the name (= quick and cheap) and only try_extension_type if the name matches
// to avoid unnecessary String allocations in ArrowError
if field.extension_type_name()? != VariantType::NAME {
return None;
}
match field.try_extension_type::<VariantType>() {
Ok(VariantType) => Some(LogicalType::Variant),
// Given check above, this should not error, but if it does ignore
Err(_e) => None,
}
Describe the solution you'd like
A clearer way to test for extension types.
Maybe the documentation I added in this PR are enough
Describe alternatives you've considered
Additional context
Is your feature request related to a problem or challenge? Please describe what you are trying to do.
As @mbrobbel pointed out in https://github.com/apache/arrow-rs/pull/8408/files#r2378240955:
There are currently two APIs for seeing if a Field has an extension type:
Field::extension_typethat panics if the field does not have the extension typeField::try_extension_typethat returns anArrowErrorif the field does not have the extension typeThere is no good API to quickly tell if a Field has an extension type. The current way is like
Works, but it requires creating an
ArrowErrorif the field is not the requested type, which is slow as it allocates a Stringin #8408 I came up with this to avoid the problem, but it is not obvious and somewhat redundant:
Describe the solution you'd like
A clearer way to test for extension types.
Maybe the documentation I added in this PR are enough
Field::try_extension_type#8475Describe alternatives you've considered
Additional context