sdf-jkl commented on PR #9677:
URL: https://github.com/apache/arrow-rs/pull/9677#issuecomment-4209390351
@alamb @scovich I was looking at #8474 and the doc update in #8475.
The current recommendation in #8475 is good:
```rust
if field.extension_type_name() == Some(MyExtensionType::NAME) {
if let Ok(extension_type) =
field.try_extension_type::<MyExtensionType>() {
// ...
}
}
```
Checking the name first avoids the two name-related error paths in
`try_new_from_field_metadata` (missing/mismatch).
For a **full validity check**, though, we currently still have to go through
`try_new_from_field_metadata`, which means:
1. `deserialize_metadata(...)`
2. `try_new(...)`
Both may return `Err`, and both are part of validation today.
I think a clean follow-up would be a dedicated `validate` API on
`ExtensionType`, with a default implementation that simply delegates to
`try_new_from_field_metadata` (or equivalent). That gives us a clearer API now
without changing behavior, and leaves room for specialized implementations
later if needed. For extensions that override it, this could also avoid
allocation/work from constructing an `ExtensionType` when we only need
validation.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]