Fix byte_range to not panic on parquet #8687
Open
+26
−22
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Which issue does this PR close?
Part of #7806
Rationale for this change
The
byte_range()method onColumnChunkMetaDatapreviously panicked if the column start or length were negative. This is undesirable in a library, as it can lead to unrecoverable errors in consumer applications.This change modifies
byte_range()to return aResult<(u64, u64)>instead, allowing callers to handle invalid byte ranges gracefully.What changes are included in this PR?
byte_range()method inparquet/src/file/metadata/mod.rsnow returns aResult.byte_range()have been updated to handle theResultusing the?operator orunwrap()in tests. This affects:parquet/examples/read_with_rowgroup.rsparquet/src/arrow/async_reader/mod.rsparquet/src/file/serialized_reader.rsAre these changes tested?
The changes are covered by existing tests. The modifications in the test files (
parquet/src/arrow/async_reader/mod.rs) now useunwrap()on thebyte_range()call, which maintains the existing test behavior of panicking on error.Are there any user-facing changes?
Yes, the signature of
parquet::file::metadata::ColumnChunkMetaData::byte_range()has changed from-> (u64, u64)to-> Result<(u64, u64)>. This is a breaking change for users who call this method directly.