rdblue commented on code in PR #5362:
URL: https://github.com/apache/iceberg/pull/5362#discussion_r932531899
##########
python/pyiceberg/expressions/base.py:
##########
@@ -342,151 +313,197 @@ def __str__(self) -> str:
@dataclass(frozen=True)
-class AlwaysTrue(BooleanExpression, ABC, Singleton):
+class AlwaysTrue(BooleanExpression, Singleton):
"""TRUE expression"""
def __invert__(self) -> AlwaysFalse:
return AlwaysFalse()
@dataclass(frozen=True)
-class AlwaysFalse(BooleanExpression, ABC, Singleton):
+class AlwaysFalse(BooleanExpression, Singleton):
"""FALSE expression"""
def __invert__(self) -> AlwaysTrue:
return AlwaysTrue()
-class IsNull(UnboundPredicate[T]):
- def __invert__(self) -> NotNull:
- return NotNull(self.term)
+@dataclass(frozen=True)
Review Comment:
If we make `__invert__` abstract, then we can't use a frozen `@dataclass`
without duplicating a lot more.
The problem is, as you pointed out, `@dataclass` can't be abstract. If I
move this to the child class, `IsNull`, then the constructor no longer supports
`term` because it is defined here in the parent. Then we have to implement
`__invert__` in each child class and define the `term` separately in each child
class.
That basically removes the benefit of using a common base class. We can no
longer rely on anything higher than the leaf class having a `term` or a set of
`literals`.
I think I'd rather trade the mypy hints for `__invert__` than not be able to
rely on inheritance for expressions. That is, if I have a `UnaryPredicate`, I
want to be able to use its `term` instead of handling everything at the leaf
level.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]