Repository navigation
fix(arith): one typed arithmetic and comparison evaluator - #156
Merged
Merged
Conversation
jsam
force-pushed
the
fix/aggregate-correctness
branch
from
October 3, 2026 10:09
3ae7ef4 to
9ae5c19
Compare
jsam
force-pushed
the
fix/typed-arithmetic
branch
from
October 3, 2026 10:12
81efe72 to
a330631
Compare
jsam
force-pushed
the
fix/aggregate-correctness
branch
from
October 3, 2026 11:01
9ae5c19 to
f75206f
Compare
Head, assignment and comparison arithmetic plus constant folding now share value::arith: checked i64 (Null on overflow), Float promotion, / as Float, Timestamp +/- Int stays Timestamp, Null for non-numeric operands. Fixes float columns failing comparisons, float constants truncated when folded, i64 wrap/panic on overflow and MIN / -1, and large ints losing precision through f64.
e(X, Y + 1) and !e(X, Y + 1) were silently read as e(X, Y). Arithmetic and function-call arguments in body and negated atoms now fail rule validation and IR building with an error that suggests binding a variable instead.
…mpare Timestamp vs Float comparisons now compare as f64 instead of failing. Folded column comparisons use arith::compare, so Null and non-numeric columns behave the same whether or not the right side is constant. Remove the int-only ArithExpr::try_eval_constant.
jsam
force-pushed
the
fix/typed-arithmetic
branch
from
October 3, 2026 11:07
a330631 to
3d29c2f
Compare
jsam
added a commit
that referenced
this pull request
Oct 3, 2026
#156's rejection test predates #154, which reports statement failures in QueryResult.errors instead of an Err. Co-authored-by: Claude Opus 5.5 <[email protected]>
jsam
added a commit
that referenced
this pull request
Oct 3, 2026
* fix(arith): evaluate arithmetic with one typed Value evaluator Head, assignment and comparison arithmetic plus constant folding now share value::arith: checked i64 (Null on overflow), Float promotion, / as Float, Timestamp +/- Int stays Timestamp, Null for non-numeric operands. Fixes float columns failing comparisons, float constants truncated when folded, i64 wrap/panic on overflow and MIN / -1, and large ints losing precision through f64. * fix(ir): reject expression arguments in body atoms e(X, Y + 1) and !e(X, Y + 1) were silently read as e(X, Y). Arithmetic and function-call arguments in body and negated atoms now fail rule validation and IR building with an error that suggests binding a variable instead. * fix(arith): compare timestamps with floats and fold through arith::compare Timestamp vs Float comparisons now compare as f64 instead of failing. Folded column comparisons use arith::compare, so Null and non-numeric columns behave the same whether or not the right side is constant. Remove the int-only ArithExpr::try_eval_constant.
jsam
added a commit
that referenced
this pull request
Oct 3, 2026
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.
What: Adds
value::arith, one evaluator for head, assignment and comparison arithmetic, plus constant folding. Ints use checked i64 ops and give Null on overflow. A Float operand promotes the result to Float, and/always gives Float.Timestamp ± Intstays a Timestamp. A non-numeric operand gives Null. Timestamp-vs-Float comparisons work. Folded and runtime comparisons treat Null the same way. Body and negated atoms with expression arguments (e(X, Y + 1)) are now rejected; before, they were silently read ase(X, Y).Why: Float columns failed comparisons and float constants were truncated when folded. i64 overflow wrapped or panicked (including
MIN / -1). Large ints lost precision going through f64. Null or String operands counted as 0.Tests: new
tests/typed_arithmetic_tests.rsplus unit tests invalue::arith.cargo fmt --check,cargo clippy --workspace --all-targets --all-features -D warningsandcargo test --workspaceall pass. Snapshot tests: 1149 passed, 0 failed.