in pyiceberg/expressions/visitors.py [0:0]
def visit_equal(self, term: BoundTerm[L], literal: Literal[L]) -> bool:
field = term.ref().field
field_id = field.field_id
if self._contains_nulls_only(field_id) or self._contains_nans_only(field_id):
return ROWS_CANNOT_MATCH
if not isinstance(field.field_type, PrimitiveType):
raise ValueError(f"Expected PrimitiveType: {field.field_type}")
if lower_bound_bytes := self.lower_bounds.get(field_id):
lower_bound = from_bytes(field.field_type, lower_bound_bytes)
if self._is_nan(lower_bound):
# NaN indicates unreliable bounds. See the InclusiveMetricsEvaluator docs for more.
return ROWS_MIGHT_MATCH
if lower_bound > literal.value: # type: ignore[operator]
return ROWS_CANNOT_MATCH
if upper_bound_bytes := self.upper_bounds.get(field_id):
upper_bound = from_bytes(field.field_type, upper_bound_bytes)
if self._is_nan(upper_bound):
# NaN indicates unreliable bounds. See the InclusiveMetricsEvaluator docs for more.
return ROWS_MIGHT_MATCH
if upper_bound < literal.value: # type: ignore[operator]
return ROWS_CANNOT_MATCH
return ROWS_MIGHT_MATCH