-
Notifications
You must be signed in to change notification settings - Fork 824
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
xmakro
committed
Sep 1, 2024
1 parent
48b9241
commit da633e4
Showing
2 changed files
with
57 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
use std::path::PathBuf; | ||
|
||
use arrow::util::test_util::parquet_test_data; | ||
use parquet::arrow::arrow_reader::ArrowReaderBuilder; | ||
|
||
#[test] | ||
fn test_datapage_v1_corrupt_checksum() { | ||
let errors = read_file_batch_errors("datapage_v1-corrupt-checksum.parquet"); | ||
assert_eq!(errors, [ | ||
Err("Parquet argument error: Parquet error: Page CRC checksum mismatch".to_string()), | ||
Ok(()), | ||
Ok(()), | ||
Err("Parquet argument error: Parquet error: Page CRC checksum mismatch".to_string()), | ||
Err("Parquet argument error: Parquet error: Not all children array length are the same!".to_string()) | ||
]); | ||
} | ||
|
||
#[test] | ||
fn test_datapage_v1_uncompressed_checksum() { | ||
let errors = read_file_batch_errors("datapage_v1-uncompressed-checksum.parquet"); | ||
assert_eq!(errors, [Ok(()), Ok(()), Ok(()), Ok(()), Ok(())]); | ||
} | ||
|
||
#[test] | ||
fn test_datapage_v1_snappy_compressed_checksum() { | ||
let errors = read_file_batch_errors("datapage_v1-snappy-compressed-checksum.parquet"); | ||
assert_eq!(errors, [Ok(()), Ok(()), Ok(()), Ok(()), Ok(())]); | ||
} | ||
|
||
|
||
#[test] | ||
fn test_plain_dict_uncompressed_checksum() { | ||
let errors = read_file_batch_errors("plain-dict-uncompressed-checksum.parquet"); | ||
assert_eq!(errors, [Ok(())]); | ||
} | ||
#[test] | ||
fn test_rle_dict_snappy_checksum() { | ||
let errors = read_file_batch_errors("rle-dict-snappy-checksum.parquet"); | ||
assert_eq!(errors, [Ok(())]); | ||
} | ||
|
||
/// Reads a file and returns a vector with one element per record batch. | ||
/// The record batch data is replaced with () and errors are stringified. | ||
fn read_file_batch_errors(name: &str) -> Vec<Result<(), String>> { | ||
let path = PathBuf::from(parquet_test_data()).join(name); | ||
println!("Reading file: {:?}", path); | ||
let file = std::fs::File::open(&path).unwrap(); | ||
let reader = ArrowReaderBuilder::try_new(file).unwrap().build().unwrap(); | ||
reader | ||
.map(|x| match x { | ||
Ok(_) => Ok(()), | ||
Err(e) => Err(e.to_string()), | ||
}) | ||
.collect() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters