Fokko commented on code in PR #4607:
URL: https://github.com/apache/iceberg-python/pull/4607#discussion_r4792105744


##########
pyiceberg/expressions/visitors.py:
##########
@@ -549,6 +550,22 @@ def visit_or(self, left_result: bool, right_result: bool) 
-> bool:
 IN_PREDICATE_LIMIT = 200
 
 
+def _collect_sorted_in_literals(expr: BooleanExpression) -> dict[int, 
list[Any]]:
+    sorted_literals: dict[int, list[Any]] = {}
+    stack: list[BooleanExpression] = [expr]
+    while stack:
+        node = stack.pop()
+        if isinstance(node, BoundIn):
+            value_set = node.value_set
+            sorted_literals[id(value_set)] = sorted(value_set)
+        elif isinstance(node, (And, Or)):
+            stack.append(node.left)
+            stack.append(node.right)
+        elif isinstance(node, Not):
+            stack.append(node.child)

Review Comment:
   mypy fails on this block in CI (`visitors.py:561: Statement is 
unreachable`). Checking `BoundIn` last makes mypy happy again:
   
   ```suggestion
           if isinstance(node, (And, Or)):
               stack.append(node.left)
               stack.append(node.right)
           elif isinstance(node, Not):
               stack.append(node.child)
           elif isinstance(node, BoundIn):
               value_set = node.value_set
               sorted_literals[id(value_set)] = sorted(value_set)
   ```



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