Skip to content

Commit

Permalink
add another test
Browse files Browse the repository at this point in the history
  • Loading branch information
etseidl committed Oct 2, 2024
1 parent 4f6785f commit b3990ae
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions parquet/src/arrow/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,38 @@ mod test {
assert_eq!(original_metadata, roundtrip_metadata);
}

#[test]
// An example of reading footer metadata from an external file, but
// page indexes from the original file.
fn test_metadata_read_write_partial_roundtrip() {
let parquet_bytes = create_parquet_file();

// read full metadata
let correct_metadata = ParquetMetaDataReader::new()
.with_page_indexes(true)
.parse_and_finish(&parquet_bytes)
.unwrap();

// read the metadata from the file WITHOUT the page index structures
let original_metadata = ParquetMetaDataReader::new()
.parse_and_finish(&parquet_bytes)
.unwrap();

// read metadata back from the serialized bytes
let metadata_bytes = metadata_to_bytes(&original_metadata);
let roundtrip_metadata = ParquetMetaDataReader::new()
.parse_and_finish(&metadata_bytes)
.unwrap();
assert_eq!(original_metadata, roundtrip_metadata);

// now retrieve page index from original file
let mut reader = ParquetMetaDataReader::new_with_metadata(roundtrip_metadata)
.with_page_indexes(true);
reader.read_page_indexes(&parquet_bytes).unwrap();
let roundtrip_metadata = reader.finish().unwrap();
assert_eq!(correct_metadata, roundtrip_metadata);
}

#[test]
// Reproducer for https://github.com/apache/arrow-rs/issues/6464 (this should eventually pass)
#[should_panic(expected = "missing required field ColumnIndex.null_pages")]
Expand Down

0 comments on commit b3990ae

Please sign in to comment.