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

Add descriptor to FixedLenStatistics #54

Merged
Merged
Show file tree
Hide file tree
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
9 changes: 4 additions & 5 deletions src/statistics/fixed_len_binary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@ use std::sync::Arc;
use parquet_format_async_temp::Statistics as ParquetStatistics;

use super::Statistics;
use crate::{
error::{ParquetError, Result},
schema::types::PhysicalType,
};
use crate::{error::{ParquetError, Result}, metadata::ColumnDescriptor, schema::types::PhysicalType};

#[derive(Debug, Clone, PartialEq)]
pub struct FixedLenStatistics {
pub descriptor: ColumnDescriptor,
pub null_count: Option<i64>,
pub distinct_count: Option<i64>,
pub max_value: Option<Vec<u8>>,
Expand All @@ -31,7 +29,7 @@ impl Statistics for FixedLenStatistics {
}
}

pub fn read(v: &ParquetStatistics, size: i32) -> Result<Arc<dyn Statistics>> {
pub fn read(v: &ParquetStatistics, size: i32, descriptor: ColumnDescriptor) -> Result<Arc<dyn Statistics>> {
if let Some(ref v) = v.max_value {
if v.len() != size as usize {
return Err(ParquetError::OutOfSpec(
Expand All @@ -48,6 +46,7 @@ pub fn read(v: &ParquetStatistics, size: i32) -> Result<Arc<dyn Statistics>> {
};

Ok(Arc::new(FixedLenStatistics {
descriptor,
null_count: v.null_count,
distinct_count: v.distinct_count,
max_value: v.max_value.clone().map(|mut x| {
Expand Down
2 changes: 1 addition & 1 deletion src/statistics/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ pub fn deserialize_statistics(
PhysicalType::Float => primitive::read::<f32>(statistics, descriptor),
PhysicalType::Double => primitive::read::<f64>(statistics, descriptor),
PhysicalType::ByteArray => binary::read(statistics, descriptor),
PhysicalType::FixedLenByteArray(size) => fixed_len_binary::read(statistics, *size),
PhysicalType::FixedLenByteArray(size) => fixed_len_binary::read(statistics, *size, descriptor),
}
}

Expand Down