You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by GitBox <gi...@apache.org> on 2022/09/06 20:06:46 UTC

[GitHub] [iceberg] rdblue commented on a diff in pull request #5303: Add a BoundBooleanExpressionVisitor for visiting bound expressions

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


##########
python/pyiceberg/expressions/base.py:
##########
@@ -672,3 +683,42 @@ def visit_unbound_predicate(self, predicate) -> BooleanExpression:
 
     def visit_bound_predicate(self, predicate) -> BooleanExpression:
         raise TypeError(f"Found already bound predicate: {predicate}")
+
+
+class BoundBooleanExpressionVisitor(BooleanExpressionVisitor[T], ABC):
+    @abstractmethod
+    def visit_in(self, ref: BoundReference[T], literals: set[Literal[Any]]) -> T:
+        """Visit the ref and literals from an In boolean expression
+        Args:
+            ref (BoundReference[T]): The ref used in the In boolean expression
+            literals (Tuple[Literal[T], ...]): The literals used in the In boolean expression
+        Raises:
+            NotImplementedError: If the concrete bound boolean expression visitor does not override this method
+        Returns:
+            R: The return type defined by the concrete bound boolean expression visitor
+        """
+
+    def visit_unbound_predicate(self, predicate: UnboundPredicate[T]):
+        """Visit an unbound predicate
+        Args:
+            predicate (UnboundPredicate[T]): An unbound predicate
+        Raises:
+            TypeError: This always raises since an unbound predicate is not expected in a bound boolean expression
+        """
+        raise TypeError(f"Not a bound predicate: {predicate}")
+
+    def visit_bound_predicate(self, predicate: BoundPredicate[T]) -> T:

Review Comment:
   I think this should call another singledispatch method that accepts a bound predicate type and a bound expression visitor, rather than calling `isinstance` itself.



-- 
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-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org