s-akhtar-baig commented on code in PR #367: URL: https://github.com/apache/iceberg-rust/pull/367#discussion_r1622705122
########## crates/iceberg/src/expr/visitors/manifest_evaluator.rs: ########## @@ -103,98 +106,264 @@ impl BoundPredicateVisitor for ManifestFilterVisitor<'_> { reference: &BoundReference, _predicate: &BoundPredicate, ) -> crate::Result<bool> { - todo!() + let field = self.field_summary_for_reference(reference); + + // contains_null encodes whether at least one partition value is null, + // lowerBound is null if all partition values are null + if self.are_all_null(field, &reference.field().field_type) { + ROWS_CANNOT_MATCH + } else { + ROWS_MIGHT_MATCH + } } fn is_nan( &mut self, reference: &BoundReference, _predicate: &BoundPredicate, ) -> crate::Result<bool> { - Ok(self - .field_summary_for_reference(reference) - .contains_nan - .is_some()) + let field = self.field_summary_for_reference(reference); + if let Some(contains_nan) = field.contains_nan { + if !contains_nan { + return ROWS_CANNOT_MATCH; + } + } + + if self.are_all_null(field, &reference.field().field_type) { + return ROWS_CANNOT_MATCH; + } + + ROWS_MIGHT_MATCH } fn not_nan( &mut self, reference: &BoundReference, _predicate: &BoundPredicate, ) -> crate::Result<bool> { - todo!() + let field = self.field_summary_for_reference(reference); + if let Some(contains_nan) = field.contains_nan { + if contains_nan && !field.contains_null && field.lower_bound.is_none() { + return ROWS_CANNOT_MATCH; + } + } + ROWS_MIGHT_MATCH } fn less_than( &mut self, reference: &BoundReference, - literal: &Datum, + datum: &Datum, _predicate: &BoundPredicate, ) -> crate::Result<bool> { - todo!() + let field = self.field_summary_for_reference(reference); + if let Some(Literal::Primitive(lower_bound)) = &field.lower_bound { + if datum.literal() <= lower_bound { + return ROWS_CANNOT_MATCH; + } + } + ROWS_MIGHT_MATCH } fn less_than_or_eq( &mut self, reference: &BoundReference, - literal: &Datum, + datum: &Datum, _predicate: &BoundPredicate, ) -> crate::Result<bool> { - todo!() + let field = self.field_summary_for_reference(reference); + if let Some(Literal::Primitive(lower_bound)) = &field.lower_bound { + if datum.literal() < lower_bound { + return ROWS_CANNOT_MATCH; + } + } + ROWS_MIGHT_MATCH } fn greater_than( &mut self, reference: &BoundReference, - literal: &Datum, + datum: &Datum, _predicate: &BoundPredicate, ) -> crate::Result<bool> { - todo!() + let field = self.field_summary_for_reference(reference); + if let Some(Literal::Primitive(upper_bound)) = &field.upper_bound { + if datum.literal() >= upper_bound { + return ROWS_CANNOT_MATCH; + } + } + ROWS_MIGHT_MATCH } fn greater_than_or_eq( &mut self, reference: &BoundReference, - literal: &Datum, + datum: &Datum, _predicate: &BoundPredicate, ) -> crate::Result<bool> { - todo!() + let field = self.field_summary_for_reference(reference); + if let Some(Literal::Primitive(upper_bound)) = &field.upper_bound { + if datum.literal() > upper_bound { + return ROWS_CANNOT_MATCH; + } + } + ROWS_MIGHT_MATCH } fn eq( &mut self, reference: &BoundReference, - literal: &Datum, + datum: &Datum, _predicate: &BoundPredicate, ) -> crate::Result<bool> { - todo!() + let field = self.field_summary_for_reference(reference); + + if field.lower_bound.is_none() || field.upper_bound.is_none() { + return ROWS_CANNOT_MATCH; + } + + if let Some(Literal::Primitive(lower_bound)) = &field.lower_bound { + if lower_bound > datum.literal() { + return ROWS_CANNOT_MATCH; + } + } + + if let Some(Literal::Primitive(upper_bound)) = &field.upper_bound { + if upper_bound < datum.literal() { + return ROWS_CANNOT_MATCH; + } + } + + ROWS_MIGHT_MATCH } fn not_eq( &mut self, - reference: &BoundReference, - literal: &Datum, + _reference: &BoundReference, + _datum: &Datum, _predicate: &BoundPredicate, ) -> crate::Result<bool> { - todo!() + // because the bounds are not necessarily a min or max value, this cannot be answered using Review Comment: Same comment here, followed https://github.com/apache/iceberg-python/blob/20f6afdf5f000ea5b167e804012f2000aa5b8573/pyiceberg/expressions/visitors.py#L658. -- 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