Repository navigation
fix: raise when binding starts-with with an out-of-range literal - #4144
Open
Shahzeb-DataEngineer wants to merge 1 commit into
Open
Shahzeb-DataEngineer wants to merge 1 commit into
Shahzeb-DataEngineer wants to merge 1 commit into
Conversation
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>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #4143
Rationale for this change
LiteralPredicate.bindfolds literals that convert toAboveMax/BelowMinintoAlwaysTrue/AlwaysFalsefor the six comparison operations, butstarts-withandnot-starts-withfell through and produced a bound predicate wrapping the sentinel itself (for example aBoundStartsWithwhose literal isIntAboveMax(), with.value == 2147483647). Row evaluation of such a predicate then crashed withAttributeError: 'int' object has no attribute 'startswith'.The Java implementation throws an
IllegalStateExceptionwhen anAboveMax/BelowMinliteral is combined with an operation that has no defined fold. This change mirrors that behavior: theAboveMax/BelowMinbranches inbindnow raise aValueErrorfor 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.pycoveringstarts-withandnot-starts-withagainst bothAboveMaxandBelowMinliterals, asserting that binding raisesValueError. Ran the fulltests/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
ValueErrorat bind time instead of producing a bound predicate that crashes evaluators later.