Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Go] array.UnionBuilder.Len implementations always return 0 #14775

Closed
nwt opened this issue Nov 29, 2022 · 1 comment
Closed

[Go] array.UnionBuilder.Len implementations always return 0 #14775

nwt opened this issue Nov 29, 2022 · 1 comment
Assignees
Milestone

Comments

@nwt
Copy link
Contributor

nwt commented Nov 29, 2022

Describe the bug, including details regarding any error messages, version, and platform.

array.(*DenseUnionBuilder).Len and array.(*SparseUnionBuilder).Len always return 0. They should instead return the number of values appended.

This bug exists because these methods are promoted (via unionBuilder) from (*builder).Len, which reads builder.length, but DenseUnionBuilder and SparseUnionBuilder don't update that field.

It is a problem because some nested type builders require working child builder Len methods. For example, at present, a ListBuilder for a union child type always builds empty lists and a MapBuilder for a union key type always builds empty maps.

One way to fix this is to add a (*unionBuilder).Len implementation that calls unionBuilder.typesBuilder.Len.

// Len returns the current number of elements in the builder.
func (b *unionBuilder) Len() int { return b.typesBuilder.Len() }

Component(s)

Go

jorisvandenbossche pushed a commit that referenced this issue Nov 30, 2022
(*DenseUnionBuilder).Len and (*SparseUnionBuilder).Len always return 0. They should instead return the number of values appended.

This bug exists because these methods are promoted (via unionBuilder) from (*builder).Len, which reads builder.length, but DenseUnionBuilder and SparseUnionBuilder don't update that field.

Fix by adding a (*unionBuilder).Len implementation that calls unionBuilder.typesBuilder.Len.

Authored-by: Noah Treuhaft <noah.treuhaft@gmail.com>
Signed-off-by: Joris Van den Bossche <jorisvandenbossche@gmail.com>
@jorisvandenbossche jorisvandenbossche added this to the 11.0.0 milestone Nov 30, 2022
@jorisvandenbossche
Copy link
Member

Issue resolved by pull request 14776
#14776

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants