-
Notifications
You must be signed in to change notification settings - Fork 602
Add support for parenthesized subquery as IN
predicate
#1793
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
58372cf
to
a2d59d6
Compare
src/parser/mod.rs
Outdated
let in_op = if self.parse_keyword(Keyword::SELECT) || self.parse_keyword(Keyword::WITH) { | ||
self.prev_token(); | ||
Expr::InSubquery { | ||
let in_op = match self.try_parse(|p| p.parse_query_body(p.dialect.prec_unknown())) { |
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.
The previous approach peeked for a SELECT
or WITH
, but we cannot rely on that because there may be more than one parenthesis, as in IN ((SELECT ...) UNION ())
.
The new approach tries to parse a subquery first, then an in list second.
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.
Yeah this makes sense!
} | ||
|
||
#[test] | ||
fn parse_in_union() { |
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 only added one test - happy to add more if deemed necessary.
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.
Thanks @adamchainz! This looks good to me overall, left one comment
src/parser/mod.rs
Outdated
let in_op = if self.parse_keyword(Keyword::SELECT) || self.parse_keyword(Keyword::WITH) { | ||
self.prev_token(); | ||
Expr::InSubquery { | ||
let in_op = match self.try_parse(|p| p.parse_query_body(p.dialect.prec_unknown())) { |
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.
Yeah this makes sense!
Marking as draft in the meantime as this is no longer pending review, @adamchainz please feel free to undraft and ping when ready! |
a2d59d6
to
feac964
Compare
IN
predicate
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! Thanks @adamchainz!
cc @alamb
Yay, thank you! |
The code train keeps on moving in this repo. very impressive |
Fixes #1792.
This is my attempt to hack in support with my minimal Rust skills. I stopped when I realized that my change of
InSubquery
to useSetExpr
for its subquery broke many tests.