1 Commits
Author SHA1 Message Date
Bijay PariyarandGeorge Panchuk 18d46069c3 fix: reject 0 raised to a negative exponent in formula PowExpression (#1429)
* fix: reject 0 raised to a negative exponent in formula PowExpression

evaluate_expression's PowExpression branch let base == 0 through the
base >= 0 check regardless of the exponent's sign, then called
math.pow(0, exponent). For a negative exponent this is a pole (division
by zero) and math.pow raises a raw ValueError: math domain error,
instead of the library's own raise_non_finite_error message that every
other non-finite case in this function produces.

Split the base >= 0 check into base > 0 (always fine) and base == 0
(fine only for a non-negative exponent), leaving the existing
base < 0 integer-exponent branch untouched. 0 raised to a non-negative
exponent still returns the expected value (0**0 == 1, 0**3 == 0).

Adds test_pow_expression to qdrant_client/local/tests/test_formula.py
covering the previously-passing cases plus the new negative-exponent
regression, alongside the existing negative-base non-integer-exponent
case.

* fix: match core's non-finite handling in formula pow

---------

Co-authored-by: George Panchuk <george.panchuk@qdrant.tech>
2026-09-16 00:28:23 +07:00