Skip to content

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

Description

@nwt

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

Activity

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions