-
Notifications
You must be signed in to change notification settings - Fork 28.1k
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
[SPARK-6740][SQL] Fix NOT operator precedence. #6326
Conversation
58a62a7
to
3d8bf9a
Compare
@@ -228,7 +228,12 @@ class SqlParser extends AbstractSparkSQLParser with DataTypeParser { | |||
andExpression * (OR ^^^ { (e1: Expression, e2: Expression) => Or(e1, e2) }) | |||
|
|||
protected lazy val andExpression: Parser[Expression] = | |||
comparisonExpression * (AND ^^^ { (e1: Expression, e2: Expression) => And(e1, e2) }) | |||
booleanFactor * (AND ^^^ { (e1: Expression, e2: Expression) => And(e1, e2) }) |
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.
Instead of bind the rule booleanFactor
with andExpression
, a better place probably be expression
rule. (https://github.com/smola/spark/blob/feature/operator-precedence/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/SqlParser.scala#L225)
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.
@chenghao-intel Not sure how. Adding the NOT clause in the expression rule would break precedence rules. Also, binding expression -> orExpression -> andExpression -> booleanFactor -> comparison is pretty much they way it is expressed in the grammars for standard SQL.
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.
Oh, sorry, my bad, I just picked up some corner case, it works.
Sorry for the delay here. Mind bringing this up to date? |
3d8bf9a
to
f9e9021
Compare
@marmbrus Done. |
ok to test |
Test build #35151 has finished for PR 6326 at commit
|
Minor style issues:
|
f9e9021
to
75b7c95
Compare
NOT has lower precedence than comparison operations.
75b7c95
to
fbc1815
Compare
Test build #35700 has finished for PR 6326 at commit
|
Test build #35701 has finished for PR 6326 at commit
|
Can one of the admins verify this patch? |
@smola do you have time to fix the test failure so we can merge this for 1.5? |
Thanks for working on this @smola. I propose we close this issue until you have time to fix the test failures. |
…tions We can't parse `NOT` operator with comparison operations like `SELECT NOT TRUE > TRUE`, this PR fixed it. Takes over apache/spark#6326. Author: Wenchen Fan <cloud0fan@outlook.com> Closes #8617 from cloud-fan/not.
NOT has lower precedence than comparison operations.