Repository navigation
Conversation
The AST, semantic analysis and the DataFusion planner already support ValueExpression::Arithmetic, but the parser never produced it, so queries such as RETURN n.age + 1 or WHERE n.age * 2 > 50 failed to parse. Parse +, -, *, / and % with the usual precedence and left associativity, and allow parenthesized sub-expressions.
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.
The AST, the semantic analyzer and the DataFusion planner already handle
ValueExpression::Arithmetic(#13, #68), but the parser never builds it, so any query with an arithmetic operator fails to parse:This adds arithmetic to
value_expression:+and-bind looser than*,/and%; all are left-associative (10 - 4 - 3is(10 - 4) - 3).(p.age + 1) * 2.WHERE p.age / 5 - 1 >= 5works too.COUNT(*)is unaffected, because the*argument is matched before the argument list is parsed.Tests:
n.age-1without spaces, arithmetic inside aWHEREcomparison, andcount(*) * 2.tests/test_arithmetic_expressions.rsrunsRETURNandWHEREarithmetic end to end on the DataFusion executor and checks the values.Commands run in
crates/lance-graph:cargo test(all unit, integration and doc tests pass),cargo fmt --all -- --check,cargo clippy --all-targets -- -D warnings.I used an AI assistant (Claude) while working on this; I reviewed and tested the change.