Skip to content

fix: raise when binding starts-with with an out-of-range literal - #4144

Open
Shahzeb-DataEngineer wants to merge 1 commit into
apache:mainfrom
Shahzeb-DataEngineer:fix/starts-with-sentinel-bind
Open

Shahzeb-DataEngineer wants to merge 1 commit into
apache:mainfrom
Shahzeb-DataEngineer:fix/starts-with-sentinel-bind

Conversation

@Shahzeb-DataEngineer

Copy link
Copy Markdown

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.

LiteralPredicate.bind folded AboveMax/BelowMin literals to AlwaysTrue or
AlwaysFalse for the comparison operations, but starts-with and
not-starts-with fell through and built a bound predicate wrapping the
sentinel itself, which then crashed evaluators. Raise a ValueError at
bind time instead, mirroring the Java implementation, which throws for
operations that have no defined fold.

Signed-off-by: Shahzeb Ali <126076773+Shahzeb-DataEngineer@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings October 23, 2026 07:27

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Binding starts-with/not-starts-with with an out-of-range literal leaks the AboveMax/BelowMin sentinel into a bound predicate

2 participants