Shahzeb-DataEngineer opened a new issue, #4143:
URL: https://github.com/apache/iceberg-python/issues/4143

   ### Apache Iceberg version
   
   main (development)
   
   ### Please describe the bug 🐞
   
   `LiteralPredicate.bind` folds literals that convert to `AboveMax` / 
`BelowMin` into `AlwaysTrue` / `AlwaysFalse` for the six comparison operations, 
but `starts-with` and `not-starts-with` fall through and produce a bound 
predicate whose literal is the sentinel itself:
   
   ```python
   from pyiceberg.expressions import StartsWith
   from pyiceberg.schema import Schema
   from pyiceberg.types import IntegerType, NestedField
   
   schema = Schema(NestedField(1, "x", IntegerType(), required=False))
   
   bound = StartsWith("x", "2147483648").bind(schema)
   # BoundStartsWith(term=BoundReference(...), literal=IntAboveMax())
   # bound.literal.value == 2147483647 (the int type maximum)
   ```
   
   Row evaluation of the resulting predicate then fails with a confusing error 
instead of a clean bind-time failure:
   
   ```
   AttributeError: 'int' object has no attribute 'startswith'
   ```
   
   The same fall-through exists for `not-starts-with` and for `BelowMin` (for 
example `StartsWith("x", "-2147483649")` produces a `BoundStartsWith` wrapping 
`IntBelowMin()`).
   
   Root cause: in `LiteralPredicate.bind` 
(`pyiceberg/expressions/__init__.py`), the `AboveMax` / `BelowMin` branches 
enumerate only the comparison operations and have no fallback for the remaining 
operations, so binding reaches `return self.as_bound(bound_term, lit)` with the 
sentinel literal.
   
   The Java implementation throws an `IllegalStateException` when an `AboveMax` 
/ `BelowMin` literal is combined with an operation that has no defined fold, so 
the sentinel never leaks into a bound predicate. PyIceberg should raise a clear 
error at bind time in the same situation.
   
   I can contribute a fix for this bug independently; a PR follows.
   


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