From fc133a23323722b3ad9792bbddb841d4d58a0519 Mon Sep 17 00:00:00 2001 From: Fokko Driesprong Date: Sun, 22 Oct 2023 10:15:47 +0200 Subject: [PATCH 1/2] Fix the tests --- tests/test_transforms.py | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/tests/test_transforms.py b/tests/test_transforms.py index d8a2151752..81a322c65b 100644 --- a/tests/test_transforms.py +++ b/tests/test_transforms.py @@ -830,15 +830,27 @@ def test_projection_truncate_string_literal_eq(bound_reference_str: BoundReferen def test_projection_truncate_string_literal_gt(bound_reference_str: BoundReference[str]) -> None: - assert TruncateTransform(2).project("name", BoundGreaterThan(term=bound_reference_str, literal=literal("data"))) == EqualTo( - term="name", literal=literal("da") - ) + assert TruncateTransform(2).project( + "name", BoundGreaterThan(term=bound_reference_str, literal=literal("data")) + ) == GreaterThanOrEqual(term="name", literal=literal("da")) def test_projection_truncate_string_literal_gte(bound_reference_str: BoundReference[str]) -> None: assert TruncateTransform(2).project( "name", BoundGreaterThanOrEqual(term=bound_reference_str, literal=literal("data")) - ) == EqualTo(term="name", literal=literal("da")) + ) == GreaterThanOrEqual(term="name", literal=literal("da")) + + +def test_projection_truncate_string_literal_lt(bound_reference_str: BoundReference[str]) -> None: + assert TruncateTransform(2).project( + "name", BoundLessThan(term=bound_reference_str, literal=literal("data")) + ) == LessThanOrEqual(term="name", literal=literal("da")) + + +def test_projection_truncate_string_literal_lte(bound_reference_str: BoundReference[str]) -> None: + assert TruncateTransform(2).project( + "name", BoundLessThanOrEqual(term=bound_reference_str, literal=literal("data")) + ) == LessThanOrEqual(term="name", literal=literal("da")) def test_projection_truncate_string_set_same_result(bound_reference_str: BoundReference[str]) -> None: From a8d873eb7ad3b67b81ac8a983f03482e15de869e Mon Sep 17 00:00:00 2001 From: Fokko Driesprong Date: Tue, 24 Oct 2023 08:21:43 -0400 Subject: [PATCH 2/2] Some more fixes --- pyiceberg/expressions/__init__.py | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/pyiceberg/expressions/__init__.py b/pyiceberg/expressions/__init__.py index 568b0dd843..0f66a5d3b3 100644 --- a/pyiceberg/expressions/__init__.py +++ b/pyiceberg/expressions/__init__.py @@ -364,7 +364,7 @@ def __init__(self, term: Union[str, UnboundTerm[Any]]): def __eq__(self, other: Any) -> bool: """Return the equality of two instances of the UnboundPredicate class.""" - return self.term == other.term if isinstance(other, UnboundPredicate) else False + return self.term == other.term if isinstance(other, self.__class__) else False @abstractmethod def bind(self, schema: Schema, case_sensitive: bool = True) -> BooleanExpression: @@ -531,7 +531,7 @@ def __repr__(self) -> str: def __eq__(self, other: Any) -> bool: """Return the equality of two instances of the SetPredicate class.""" - return self.term == other.term and self.literals == other.literals if isinstance(other, SetPredicate) else False + return self.term == other.term and self.literals == other.literals if isinstance(other, self.__class__) else False def __getnewargs__(self) -> Tuple[UnboundTerm[L], Set[Literal[L]]]: """Pickle the SetPredicate class.""" @@ -664,12 +664,6 @@ def __invert__(self) -> In[L]: """Transform the Expression into its negated version.""" return In[L](self.term, self.literals) - def __eq__(self, other: Any) -> bool: - """Return the equality of two instances of the NotIn class.""" - if isinstance(other, NotIn): - return self.term == other.term and self.literals == other.literals - return False - @property def as_bound(self) -> Type[BoundNotIn[L]]: return BoundNotIn[L]