Shahzeb-DataEngineer opened a new pull request, #4144: URL: https://github.com/apache/iceberg-python/pull/4144
Closes #4143 # Rationale for this change `LiteralPredicate.bind` folds literals that convert to `AboveMax` / `BelowMin` into `AlwaysTrue` / `AlwaysFalse` for the six comparison operations, but `starts-with` and `not-starts-with` fell through and produced a bound predicate wrapping the sentinel itself (for example a `BoundStartsWith` whose literal is `IntAboveMax()`, with `.value == 2147483647`). Row evaluation of such a predicate then crashed with `AttributeError: 'int' object has no attribute 'startswith'`. The Java implementation throws an `IllegalStateException` when an `AboveMax` / `BelowMin` literal is combined with an operation that has no defined fold. This change mirrors that behavior: the `AboveMax` / `BelowMin` branches in `bind` now raise a `ValueError` for the remaining operations instead of leaking the sentinel into a bound predicate. The comparison-operation folds are unchanged. ## Are these changes tested? Yes. Added a parametrized regression test in `tests/expressions/test_expressions.py` covering `starts-with` and `not-starts-with` against both `AboveMax` and `BelowMin` literals, asserting that binding raises `ValueError`. Ran the full `tests/expressions/` suite locally; all 586 tests pass. ## Are there any user-facing changes? Yes: binding a starts-with / not-starts-with predicate with an out-of-range literal now raises a clear `ValueError` at bind time instead of producing a bound predicate that crashes evaluators later. -- 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]
