Skip to content

[Variant] Remove superfluous check when validating monotonic offsets #7900

@friendlymatthew

Description

@friendlymatthew

This is a follow on from #7878

Per the spec, VariantList and VariantMetadata must have offsets encoded in monotonically increasing order.

We currently do this here:

// Validate offsets are in-bounds and monotonically increasing.
// Since shallow verification checks whether the first and last offsets are in-bounds,
// we can also verify all offsets are in-bounds by checking if offsets are monotonically increasing.
let are_offsets_monotonic = offsets.is_sorted_by(|a, b| a < b);
if !are_offsets_monotonic {
return Err(ArrowError::InvalidArgumentError(
"offsets are not monotonically increasing".to_string(),
));
}

and

// Validate offsets are in-bounds and monotonically increasing.
// Since shallow validation ensures the first and last offsets are in bounds, we can also verify all offsets
// are in-bounds by checking if offsets are monotonically increasing.
let are_offsets_monotonic = offsets.is_sorted_by(|a, b| a < b);
if !are_offsets_monotonic {
return Err(ArrowError::InvalidArgumentError(
"offsets not monotonically increasing".to_string(),
));
}

Since we later loop over these offsets to access elements in the respective buffers, any non-monotonic offset range would err when accessing elements.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementAny new improvement worthy of a entry in the changelogparquetChanges to the parquet crate

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions