rdblue commented on code in PR #6139:
URL: https://github.com/apache/iceberg/pull/6139#discussion_r1024479325


##########
python/pyiceberg/expressions/__init__.py:
##########
@@ -194,85 +251,108 @@ def __new__(cls, child: BooleanExpression):
             return AlwaysTrue()
         elif isinstance(child, Not):
             return child.child
-        result = super().__new__(cls)
-        object.__setattr__(result, "child", child)
-        return result
+        obj = super().__new__(cls)
+        obj.child = child
+        return obj
+
+    def __repr__(self) -> str:
+        return f"Not(child={repr(self.child)})"
+
+    def __eq__(self, other: Any) -> bool:
+        return self.child == other.child if isinstance(other, Not) else False
 
     def __invert__(self) -> BooleanExpression:
         return self.child
 
 
-@dataclass(frozen=True)
 class AlwaysTrue(BooleanExpression, Singleton):
     """TRUE expression"""
 
     def __invert__(self) -> AlwaysFalse:
         return AlwaysFalse()
 
+    def __str__(self):
+        return "AlwaysTrue()"
+
+    def __repr__(self):
+        return "AlwaysTrue()"
+
 
-@dataclass(frozen=True)
 class AlwaysFalse(BooleanExpression, Singleton):
     """FALSE expression"""
 
     def __invert__(self) -> AlwaysTrue:
         return AlwaysTrue()
 
+    def __str__(self):
+        return "AlwaysFalse()"
+
+    def __repr__(self):
+        return "AlwaysFalse()"
 
-@dataclass(frozen=True)
-class BoundPredicate(Generic[T], Bound, BooleanExpression):
-    term: BoundTerm[T]
 
-    def __invert__(self) -> BoundPredicate[T]:
-        """Inverts the predicate"""
-        raise NotImplementedError
+class BoundPredicate(Generic[L], Bound, BooleanExpression, ABC):
+    term: BoundTerm[L]
 
+    def __init__(self, term: BoundTerm[L]):
+        self.term = term
 
-@dataclass(frozen=True)
-class UnboundPredicate(Generic[T], Unbound[BooleanExpression], 
BooleanExpression):
-    as_bound: ClassVar[type]
-    term: UnboundTerm[T]
+    def __eq__(self, other: Any) -> bool:
+        if isinstance(other, BoundPredicate):
+            return self.term == other.term
+        return False
 
-    def __invert__(self) -> UnboundPredicate[T]:
-        """Inverts the predicate"""
-        raise NotImplementedError
 
-    def bind(self, schema: Schema, case_sensitive: bool = True) -> 
BooleanExpression:
-        """Binds the predicate to a schema"""
-        raise NotImplementedError
+class UnboundPredicate(Unbound, BooleanExpression, ABC):
+    term: UnboundTerm
 
+    def __init__(self, term: Union[str, UnboundTerm]):
+        self.term = _to_unbound_term(term)
+
+    def __eq__(self, other):
+        return self.term == other.term if isinstance(other, UnboundPredicate) 
else False
+
+    @abstractmethod
+    def bind(self, schema: Schema, case_sensitive: bool = True) -> 
BoundPredicate:
+        ...
 
-@dataclass(frozen=True)
-class UnaryPredicate(UnboundPredicate[T]):
-    def bind(self, schema: Schema, case_sensitive: bool = True) -> 
BooleanExpression:
+    @property
+    @abstractmethod
+    def as_bound(self) -> Type[BoundPredicate]:
+        ...
+
+
+class UnaryPredicate(UnboundPredicate, ABC):

Review Comment:
   Shouldn't this extend `UnboundPredicate[Any]`?



-- 
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

Reply via email to