prql
prql copied to clipboard
fix: BETWEEN optimization now triggers by comparing expr kind, not span
Summary
- Fixes the
try_into_betweenoptimization which was dead code since it comparedrq::Exprvalues including theirspanfield - Changes comparison from
a_l == b_l(full Expr including span) toa_l.kind == b_l.kind(semantic content only) - Adds regression test verifying BETWEEN is now generated
Fixes #5737
Before
from t | filter (a >= 5 && a <= 10)
Generated:
SELECT * FROM t WHERE a >= 5 AND a <= 10
After
SELECT * FROM t WHERE a BETWEEN 5 AND 10
Root Cause
rq::Expr derives PartialEq which includes the span field. The same column a referenced at two different source positions has the same CId but different Span values, so the equality check a_l == b_l always failed.
Test plan
- [x] Added
test_between_optimizationregression test - [x] All 450 prqlc tests pass (including new test)
- [x] Change is a one-line fix in the comparison logic
Generated with Claude Code