You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
Data type Union([(0, Field { name: "Integer", data_type: Int32, nullable: false, dict_id: 0, dict_is_ordered: false, metadata: {} }), (1, Field { name: "Float", data_type: Float32, nullable: false, dict_id: 0, dict_is_ordered: false, metadata: {} })], Sparse) is not currently supported
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 a UnionBuilder for a field:
let mut builder = StructBuilder::from_fields(
get_struct_fields(),
3,
);
let union_field = builder.field_builder::<UnionBuilder>(1);
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 the ArrayBuilder trait, which is required for the dynamic API and internals of StructBuilder. This is because ArrayBuilder requires a finish(&mut self) -> ArrayRef, and the UnionBuilder has a build(self) -> Result<UnionArray, ArrowError> (consumes the builder AND can fail).
Changing self to &mut self shouldn't be too hard, but the Result 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:
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: