Support Union types in StructBuilder
#6349
Labels
enhancement
Any new improvement worthy of a entry in the changelog
StructBuilder
#6349
Is your feature request related to a problem or challenge? Please describe what you are trying to do.
I'm trying to use
StructBuilder
to create a struct whose one field is of a Union type. This is currently unsupported, see this small repro (crate version v52.2.0):This results in a panic from
builder/struct_builder.rs:278:14
:The particular layout of the union doesn't matter, neither does whether it's sparse or dense.
Describe the solution you'd like
I'd like to use
StructBuilder
with a Union field the same way it works with other field types. In particular, I should be able to retrieve aUnionBuilder
for a field:Describe alternatives you've considered
I don't actually know how to work around this. It'd be appreciated if someone could show me how to build a struct array with a schema like this without using the builder, so I can unblock myself.
Additional context
As far as I understand the main issue is that
UnionBuilder
does not implement theArrayBuilder
trait, which is required for the dynamic API and internals ofStructBuilder
. This is becauseArrayBuilder
requires afinish(&mut self) -> ArrayRef
, and theUnionBuilder
has abuild(self) -> Result<UnionArray, ArrowError>
(consumes the builder AND can fail).Changing
self
to&mut self
shouldn't be too hard, but theResult
semantics are rather hard. I'm not sure what the implementation path would be here.The text was updated successfully, but these errors were encountered: