Skip to content
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
6 changes: 3 additions & 3 deletions pyiceberg/expressions/visitors.py
Original file line number Diff line number Diff line change
Expand Up @@ -1874,10 +1874,10 @@ def visit_is_nan(self, term: BoundTerm) -> BooleanExpression:

def visit_not_nan(self, term: BoundTerm) -> BooleanExpression:
val = term.eval(self.struct)
if isinstance(val, SupportsFloat) and not math.isnan(val):
return self.visit_true()
else:
if isinstance(val, SupportsFloat) and math.isnan(val):
return self.visit_false()
else:
return self.visit_true()
Comment on lines +1877 to +1880

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

previously for None, isinstance(None, SupportsFloat) is false, so it returned AlwaysFalse().


def visit_less_than(self, term: BoundTerm, literal: LiteralValue) -> BooleanExpression:
if term.eval(self.struct) < literal.value:
Expand Down
6 changes: 6 additions & 0 deletions tests/expressions/test_residual_evaluator.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,9 @@ def test_is_not_nan() -> None:
res_eval = residual_evaluator_of(spec=spec, expr=predicate, case_sensitive=True, schema=schema)

residual = res_eval.residual_for(Record(None))
assert residual == AlwaysTrue()

residual = res_eval.residual_for(Record(float("nan")))
Comment on lines 213 to +216

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

None is now true.
NaN is now false.

assert residual == AlwaysFalse()

residual = res_eval.residual_for(Record(2))
Expand All @@ -223,6 +226,9 @@ def test_is_not_nan() -> None:
res_eval = residual_evaluator_of(spec=spec, expr=predicate, case_sensitive=True, schema=schema)

residual = res_eval.residual_for(Record(None))
assert residual == AlwaysTrue()

residual = res_eval.residual_for(Record(float("nan")))
assert residual == AlwaysFalse()

residual = res_eval.residual_for(Record(2))
Expand Down