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.
This is a follow on from #7878
Per the spec,
VariantListandVariantMetadatamust have offsets encoded in monotonically increasing order.We currently do this here:
arrow-rs/parquet-variant/src/variant/list.rs
Lines 222 to 230 in 387490a
and
arrow-rs/parquet-variant/src/variant/metadata.rs
Lines 240 to 248 in 387490a
Since we later loop over these offsets to access elements in the respective buffers, any non-monotonic offset range would err when accessing elements.