samredai commented on code in PR #4816:
URL: https://github.com/apache/iceberg/pull/4816#discussion_r879996394


##########
python/src/iceberg/expressions/base.py:
##########
@@ -267,6 +226,68 @@ def __str__(self) -> str:
         return "false"
 
 
+class UnboundIn(BooleanExpression, UnboundPredicate):
+    """IN operation expression"""
+
+    def __init__(self, left: "UnboundReference", right: List[Literal]):
+        self._left = left
+        self._right = right
+
+    @property
+    def ref(self) -> "UnboundReference":
+        return self._left
+
+    @property
+    def list(self) -> List[Literal]:
+        return self._right
+
+    def __eq__(self, other) -> bool:
+        return id(self) == id(other) or (isinstance(other, UnboundIn) and 
self.ref == other.ref and self.list == other.list)
+
+    def __invert__(self) -> Not:
+        return Not(self)
+
+    def __repr__(self) -> str:
+        return f"UnboundIn({repr(self.ref)}, {repr(self.list)})"
+
+    def __str__(self) -> str:
+        return f"({self.ref} in {self.list})"
+
+    def bind(self, schema: Schema, case_sensitive: bool) -> "In":
+        return In(self.ref.bind(schema, case_sensitive), self.list)
+
+
+class In(BooleanExpression, BoundPredicate):
+    """IN operation expression"""
+
+    def __init__(self, left: "BoundReference", right: List[Literal]):
+        self._left = left
+        self._right = right
+
+    @property
+    def ref(self) -> "BoundReference":

Review Comment:
   I think the `ref` property and `list` property should be named `left` and 
`right` respectively so that the visitor methods can stay consistent in terms 
of naming. As an example, here's what I did in PR #4815 for the method 
dispatched for `And`:
   ```py
   @visit.register(And)
   def _(obj: And, visitor: BooleanExpressionVisitor[T]) -> T:
       """Visit an And boolean expression with a concrete 
BooleanExpressionVisitor"""
       left_result: T = visit(obj.left, visitor=visitor)
       right_result: T = visit(obj.right, visitor=visitor)
       return visitor.visit_and(left_result=left_result, 
right_result=right_result)
   ```
   Once this PR is in, we would add a `visit` dispatch method for 
`UnboundPredicate`/`BoundPredicate` that looks like:
   ```py
   @visit.register(UnboundPredicate)
   def _(obj: UnboundPredicate, visitor: BooleanExpressionVisitor[T]) -> T:
       """Visit an unbound predicate with a concrete BooleanExpressionVisitor"""
       left_result: T = visit(obj.left, visitor=visitor)
       right_result: T = visit(obj.right, visitor=visitor)
       return visitor.visit_unbound_predicate(left_result=left_result, 
right_result=right_result)
   
   @visit.register(BoundPredicate)
   def _(obj: BoundPredicate, visitor: BooleanExpressionVisitor[T]) -> T:
       """Visit a bound predicate with a concrete BooleanExpressionVisitor"""
       left_result: T = visit(obj.left, visitor=visitor)
       right_result: T = visit(obj.right, visitor=visitor)
       return visitor.visit_bound_predicate(left_result=left_result, 
right_result=right_result)
   ```



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

Reply via email to