Xuanwo commented on code in PR #794: URL: https://github.com/apache/iceberg-rust/pull/794#discussion_r1884928592
########## crates/iceberg/src/spec/manifest.rs: ########## @@ -128,7 +130,61 @@ pub struct ManifestWriter { key_metadata: Vec<u8>, - field_summary: HashMap<i32, FieldSummary>, + partitions: Vec<Struct>, +} + +struct PartitionFieldStats { + partition_type: PrimitiveType, + summary: FieldSummary, +} + +impl PartitionFieldStats { + pub(crate) fn new(partition_type: PrimitiveType) -> Self { + Self { + partition_type, + summary: Default::default(), + } + } + + pub(crate) fn update(&mut self, value: Option<PrimitiveLiteral>) -> Result<()> { + if let Some(value) = value { + if !self.partition_type.compatible(&value) { + return Err(Error::new( + ErrorKind::DataInvalid, + "value is not compatitable with type", + )); + } + let value = Datum::new(self.partition_type.clone(), value); + if value.is_nan() { + self.summary.contains_nan = Some(true); + } else { + if let Some(lower) = self.summary.lower_bound.as_mut() { + if value < *lower { + *lower = value.clone(); + } + } else { + self.summary.lower_bound = Some(value.clone()); + } + if let Some(upper) = self.summary.upper_bound.as_mut() { + if value > *upper { + *upper = value; + } + } else { + self.summary.upper_bound = Some(value); + } + } Review Comment: Thank you for the feedback. I just realized that `max` requires `T: Ord`. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org For additional commands, e-mail: issues-h...@iceberg.apache.org