#[derive(Debug, Clone, Default)]
pub struct ColumnStats {
pub name: String,
pub count: usize,
pub unique_count: usize,
pub null_count: usize,
pub all_integers: bool,
pub all_numeric: bool,
pub min_str_len: Option<usize>,
pub max_str_len: Option<usize>,
pub avg_str_len: Option<f32>,
pub looks_like_datetime: bool,
pub is_array: bool,
pub array_len: Option<usize>,
pub sample_values: Vec<String>,
}
impl ColumnStats {
pub fn new(name: impl Into<String>) -> Self {
Self { name: name.into(), ..Default::default() }
}
pub fn cardinality_ratio(&self) -> f32 {
if self.count == 0 {
0.0
} else {
self.unique_count as f32 / self.count as f32
}
}
pub fn null_ratio(&self) -> f32 {
if self.count == 0 {
0.0
} else {
self.null_count as f32 / self.count as f32
}
}
}