Skip to content

Ensure there is a single zero in the offsets buffer for an empty ListArray. #1620

@alamb

Description

@alamb

Good idea checking the C++ version. The docs for binary layout also mention

The offsets buffer contains length + 1 signed integers
...
and the last slot is the length of the values array

which would mean there has to be a single zero in the offsets buffer for an empty ListArray.

If this is a requirements it would be better to validate it when creating ArrayData. The code in ArrayData::validate_each_offset explicitly allow this case though:

        // An empty binary-like array can have 0 offsets
        if self.len == 0 && offset_buffer.is_empty() {
            return Ok(());
        }

I'm more hesitant to change this now, maybe let's wait for some more eyes on this.

Originally posted by @jhorstmann in #1602 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions