viirya opened a new issue, #5098:
URL: https://github.com/apache/arrow-rs/issues/5098
**Is your feature request related to a problem or challenge? Please describe
what you are trying to do.**
<!--
A clear and concise description of what the problem is. Ex. I'm always
frustrated when [...]
(This section helps Arrow developers understand the context and *why* for
this feature, in addition to the *what*)
-->
I'm working on something to build various array builders (could be nested)
based on different data types. The purpose is to have builders used to append
values from values of rows.
For primitive and struct types, they are working well.
But `ListBuilder` (I think `MapBuilder` is same) is an exception. Its API
design (it has a type parameter `T: ArrayBuilder`) is different from other
builders. This inconsistency makes harder to put `ListBuilder` as a same piece
like other builders.
For example, this crate has an API `make_builder` which returns `Box<dyn
ArrayBuilder>`. Ideally, for `ListBuilder` we should be able to do:
```rust
DataType::List(field) => {
let mut builder = make_builder(field.data_type(), capacity);
Box::new(ListBuilder::with_capacity(builder, capacity))
}
```
But we cannot do it because `ListBuilder` requires type parameter of its
value builder. We can write a macro to do
`into_box_any().downcast::<$builder_type>` on the returned `Box<dyn
ArrayBuilder>` from `make_builder` to get concrete owned value of value
builder. But it only works for primitive builers.
For nested list types, we need to have nested type parameter of the nested
`ListBuilder` type. I'm not sure how we can dynamically create a deeply nested
type parameter in runtime?
**Describe the solution you'd like**
<!--
A clear and concise description of what you want to happen.
-->
I am wondering if we can remove the type parameter from `ListBuilder` and
make its value builder as `Box<dyn ArrayBuilder>` as `StructBuilder`.
**Describe alternatives you've considered**
<!--
A clear and concise description of any alternative solutions or features
you've considered.
-->
**Additional context**
<!--
Add any other context or screenshots about the feature request here.
-->
--
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]