-
Notifications
You must be signed in to change notification settings - Fork 583
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
Fix interval parsing logic and precedence #705
Conversation
Pull Request Test Coverage Report for Build 3491640784
💛 - Coveralls |
@@ -363,6 +363,36 @@ impl<'a> Parser<'a> { | |||
Ok(expr) | |||
} | |||
|
|||
pub fn parse_interval_expr(&mut self) -> Result<Expr, ParserError> { |
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 wonder if you investigated following a similar pattern to NOT
which adjusts the precedence based on peeking in the token stream?
I couldn't find any example of a similar partten in the codebase
https://github.com/search?q=repo%3Asqlparser-rs%2Fsqlparser-rs%20parse_infix&type=code
What do you think @AugustoFKL ?
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.
@alamb I think we may need to refactor the expression parsing...
With the current structure, we end up with no such good expansion of expressions to parse. And there's still the (big) problem with precedence analysis.
But, for now, and considering the scope of this PR, I think that's OK. Doing it for NOT
would be better in another PR, right?
Thank you for the contribution @sarahyurick |
Thanks @alamb @AugustoFKL ! Let me know what you think. Should I update anything with the precedence logic, or just keep as is for now? |
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.
lgtm
@sarahyurick IMHO that's ok
Thanks again @sarahyurick and @AugustoFKL |
Recheck this after rebase on commit 57083a0 "Fix interval parsing logic and precedence (apache#705)", first released in 0.28.0
Recheck this after rebase on commit 57083a0 "Fix interval parsing logic and precedence (apache#705)", first released in 0.28.0
Recheck this after rebase on commit 57083a0 "Fix interval parsing logic and precedence (apache#705)", first released in 0.28.0
Recheck this after rebase on commit 57083a0 "Fix interval parsing logic and precedence (apache#705)", first released in 0.28.0
I originally opened an issue for this on the DataFusion side: apache/datafusion#3944, but found the error to lie in how the queries were being parsed.
These changes allow something like
"SELECT col FROM test WHERE d3_date > d1_date + INTERVAL '5 days' AND d2_date > d1_date + INTERVAL '3 days'"
to be parsed correctly. Previously, the '5 days' was getting separated from theINTERVAL
keyword and lumped into theAND
operator.