Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate methods from footer.rs in favor of ParquetMetaDataReader #6451

Merged
merged 3 commits into from
Sep 26, 2024

Conversation

etseidl
Copy link
Contributor

@etseidl etseidl commented Sep 24, 2024

Which issue does this PR close?

Part of #6447

Rationale for this change

See issue

What changes are included in this PR?

Add deprecation warnings to public methods in footer.rs (parse_metadata, decode_metadata, decode_footer) and replace usages with equivalent functions from ParquetMetaDataReader.

Are there any user-facing changes?

No

@github-actions github-actions bot added the parquet Changes to the parquet crate label Sep 24, 2024
}

#[cfg(test)]
mod tests {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These tests are all replicated in parquet/src/file/metadata/reader.rs

Copy link
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks again @etseidl -- I think the code in this PR looks great.

Also, I know it was more work, but breaking them up into multiple PRs has made reviewing it much easier (though I admit it is still taking pretty long)

@@ -382,7 +381,7 @@ impl ArrowReaderMetadata {
/// `Self::metadata` is missing the page index, this function will attempt
/// to load the page index by making an object store request.
pub fn load<T: ChunkReader>(reader: &T, options: ArrowReaderOptions) -> Result<Self> {
let mut metadata = footer::parse_metadata(reader)?;
let mut metadata = ParquetMetaDataReader::new().parse_and_finish(reader)?;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So beautiful 👏

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There will be a small conflict here with #6450. I couldn't use the new API for the page indexes until the behavior change was dealt with.

@@ -51,34 +42,9 @@ use crate::schema::types::{self, SchemaDescriptor};
/// # See Also
/// [`decode_metadata`] for decoding the metadata from the bytes.
/// [`decode_footer`] for decoding the metadata length from the footer.
#[deprecated(since = "53.1.0", note = "Use ParquetMetaDataReader")]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

use crate::schema::types::Type as SchemaType;

#[test]
fn test_parse_metadata_size_smaller_than_footer() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I verified that these tests have already been ported to the reader module:

fn test_parse_metadata_size_smaller_than_footer() {
let test_file = tempfile::tempfile().unwrap();
let err = ParquetMetaDataReader::parse_metadata(&test_file).unwrap_err();
assert!(matches!(err, ParquetError::IndexOutOfBound(8, _)));
}
#[test]
fn test_parse_metadata_corrupt_footer() {
let data = Bytes::from(vec![1, 2, 3, 4, 5, 6, 7, 8]);
let reader_result = ParquetMetaDataReader::parse_metadata(&data);
assert_eq!(
reader_result.unwrap_err().to_string(),
"Parquet error: Invalid Parquet file. Corrupt footer"
);
}

@etseidl
Copy link
Contributor Author

etseidl commented Sep 25, 2024

Also, I know it was more work, but breaking them up into multiple PRs has made reviewing it much easier (though I admit it is still taking pretty long)

Yes, #6392 was monstrous (and reviewing this had to be tedious). I'll do what I can to lighten your load as we move forward.

@alamb alamb merged commit 2cc0c16 into apache:master Sep 26, 2024
16 checks passed
@alamb
Copy link
Contributor

alamb commented Sep 26, 2024

Looking very nice -- thanks @etseidl

@etseidl etseidl deleted the deprecate_footer branch September 26, 2024 15:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
parquet Changes to the parquet crate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants