rdblue commented on code in PR #4815:
URL: https://github.com/apache/iceberg/pull/4815#discussion_r877594911
##########
python/src/iceberg/expressions/base.py:
##########
@@ -346,3 +346,116 @@ def bind(self, schema: Schema, case_sensitive: bool) ->
BoundReference:
raise ValueError(f"Cannot find field '{self.name}' in schema:
{schema}")
return BoundReference(field=field,
accessor=schema.accessor_for_field(field.field_id))
+
+
+class BooleanExpressionVisitor(ABC):
+ @abstractmethod
+ def visit_always_true(self) -> BooleanExpression:
+ """Visit method for an AlwaysTrue boolean expression
+
+ Note: This visit method has no arguments since AlwaysTrue instances
have no context.
+
+ Returns:
+ BooleanExpression: The resulting expression after any
modifications performed by the visitor
+ """
+
+ @abstractmethod
+ def visit_always_false(self) -> BooleanExpression:
+ """Visit method for an AlwaysFalse boolean expression
+
+ Note: This visit method has no arguments since AlwaysFalse instances
have no context.
+
+ Returns:
+ BooleanExpression: The resulting expression after any
modifications performed by the visitor
+ """
+
+ @abstractmethod
+ def visit_not(self, result: BooleanExpression) -> BooleanExpression:
+ """Visit method for a Not boolean expression
+
+ Args:
+ left (BooleanExpression): The left side of the expression
+ right (BooleanExpression): The right side of the expression
+
+ Returns:
+ BooleanExpression: The resulting expression after any
modifications performed by the visitor
+ """
+
+ @abstractmethod
+ def visit_and(self, left: BooleanExpression, right: BooleanExpression) ->
BooleanExpression:
+ """Visit method for an And boolean expression
+
+ Args:
+ left (BooleanExpression): The left side of the expression
+ right (BooleanExpression): The right side of the expression
+
+ Returns:
+ BooleanExpression: The resulting expression after any
modifications performed by the visitor
+ """
+
+ @abstractmethod
+ def visit_or(self, left: BooleanExpression, right: BooleanExpression) ->
BooleanExpression:
+ """Visit method for an Or boolean expression
+
+ Args:
+ left (BooleanExpression): The left side of the expression
+ right (BooleanExpression): The right side of the expression
+
+ Returns:
+ BooleanExpression: The resulting expression after any
modifications performed by the visitor
+ """
+
+ @abstractmethod
+ def visit_predicate(self, predicate):
Review Comment:
I think it would be better to have `visit_unbound_predicate` and
`visit_bound_predicate` so the implementation doesn't have to do an
`isinstance` check.
--
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]