-
Notifications
You must be signed in to change notification settings - Fork 615
fix: unary negation operator with operators: Mul
, Div
and Mod
#902
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Pull Request Test Coverage Report for Build 5346759290
💛 - Coveralls |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @izveigor -- this makes sense to me
#[test] | ||
fn parse_unary_math_with_multiply() { | ||
use self::Expr::*; | ||
let sql = "-a * -b"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I ran this case without any of the code changes in this PR and it fails like the following (aka it is parased as -(a * -b)
---- parse_unary_math_with_multiply stdout ----
thread 'parse_unary_math_with_multiply' panicked at 'assertion failed: `(left == right)`
left: `BinaryOp { left: UnaryOp { op: Minus, expr: Identifier(Ident { value: "a", quote_style: None }) }, op: Multiply, right: UnaryOp { op: Minus, expr: Identifier(Ident { value: "b", quote_style: None }) } }`,
right: `UnaryOp { op: Minus, expr: BinaryOp { left: Identifier(Ident { value: "a", quote_style: None }), op: Multiply, right: UnaryOp { op: Minus, expr: Identifier(Ident { value: "b", quote_style: None }) } } }`', tests/sqlparser_common.rs:1100:5
stack backtrace:
…pache#902) Can drop this after rebase on commit 8877cba " fix: unary negation operator with operators: Mul, Div and Mod (apache#902)", first released in 0.35.0
…pache#902) Can drop this after rebase on commit 8877cba " fix: unary negation operator with operators: Mul, Div and Mod (apache#902)", first released in 0.35.0
One part of apache/datafusion#6649.
Unary operator does not work correctly with operators:
Mul
,Div
andMod
.For example (Arrow-Datafusion):
But should be:
The main problem is the wrong precedence (See https://github.com/sqlparser-rs/sqlparser-rs/blob/main/src/parser.rs#L797)