Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 38 additions & 2 deletions parquet/src/file/statistics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,13 +210,21 @@ pub(crate) fn from_thrift_page_stats(
Type::INT96 => {
// INT96 statistics may not be correct, because comparison is signed
let min = if let Some(data) = min {
assert_eq!(data.len(), 12);
if data.len() != 12 {
return Err(ParquetError::General(
"Incorrect Int96 min statistics".to_string(),
));
}
Some(Int96::try_from_le_slice(&data)?)
} else {
None
};
let max = if let Some(data) = max {
assert_eq!(data.len(), 12);
if data.len() != 12 {
return Err(ParquetError::General(
"Incorrect Int96 max statistics".to_string(),
));
}
Some(Int96::try_from_le_slice(&data)?)
} else {
None
Expand Down Expand Up @@ -1085,4 +1093,32 @@ mod tests {
is_min_max_deprecated,
))
}

#[test]
fn test_int96_invalid_statistics() {
let mut thrift_stats = PageStatistics {
max: None,
min: Some((0..13).collect()),
null_count: Some(0),
distinct_count: None,
max_value: None,
min_value: None,
is_max_value_exact: None,
is_min_value_exact: None,
};

let err = from_thrift_page_stats(Type::INT96, Some(thrift_stats.clone())).unwrap_err();
assert_eq!(
err.to_string(),
"Parquet error: Incorrect Int96 min statistics"
);

thrift_stats.min = None;
thrift_stats.max = Some((0..13).collect());
let err = from_thrift_page_stats(Type::INT96, Some(thrift_stats)).unwrap_err();
assert_eq!(
err.to_string(),
"Parquet error: Incorrect Int96 max statistics"
);
}
}
Loading