scovich commented on PR #9092:
URL: https://github.com/apache/arrow-rs/pull/9092#issuecomment-3712107261

   > I tried to implement Array for external types but was never able to get 
the downcasting working because of the closed nature of DataType. So I don't 
think it was previously possible to implement Array externally: sealing the 
array just makes it explicit
   
   When implementing the variant extension type, we also tried to use`Array`, 
but we hit the same 1:1 constraint -- every concrete `Array` must have a 
corresponding `DataType` enum variant in order for upcasting to work properly, 
and every `DataType` enum variant must have its own concrete type implementing 
`Array` for the same reason. In our case, the (proposed) `Array::data_type` 
method for `VariantArray` had to return `DataType::Struct`, but attempting to 
upcast it as `StructArray` would fail/panic.
   
   Aside: the same 1:1 constrait is also why `Array` cannot (and must never) 
require `Any`, even tho it makes casting a lot harder. Because `&dyn Array` and 
`Arc<dyn Array>` both impl Array (as does `&Arc<Arc<dyn Array>>` by 
transitivity) attempting any kind of casting via `Array: Any` would wreak havoc 
whenever those convenience wrapper impl are involved. 


-- 
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]

Reply via email to