Skip to content
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

Cleanup: avoid using unreachable! when parsing semi/anti join #738

Merged
merged 1 commit into from Nov 30, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
37 changes: 20 additions & 17 deletions src/parser.rs
Expand Up @@ -4832,6 +4832,7 @@ impl<'a> Parser<'a> {
}
kw @ Keyword::LEFT | kw @ Keyword::RIGHT => {
let _ = self.next_token();
let is_left = kw == Keyword::LEFT;
let join_type = self.parse_one_of_keywords(&[
Keyword::OUTER,
Keyword::SEMI,
Expand All @@ -4841,33 +4842,35 @@ impl<'a> Parser<'a> {
match join_type {
Some(Keyword::OUTER) => {
self.expect_keyword(Keyword::JOIN)?;
match kw {
Keyword::LEFT => JoinOperator::LeftOuter,
Keyword::RIGHT => JoinOperator::RightOuter,
_ => unreachable!(),
if is_left {
JoinOperator::LeftOuter
} else {
JoinOperator::RightOuter
}
}
Some(Keyword::SEMI) => {
self.expect_keyword(Keyword::JOIN)?;
match kw {
Keyword::LEFT => JoinOperator::LeftSemi,
Keyword::RIGHT => JoinOperator::RightSemi,
_ => unreachable!(),
if is_left {
JoinOperator::LeftSemi
} else {
JoinOperator::RightSemi
}
}
Some(Keyword::ANTI) => {
self.expect_keyword(Keyword::JOIN)?;
match kw {
Keyword::LEFT => JoinOperator::LeftAnti,
Keyword::RIGHT => JoinOperator::RightAnti,
_ => unreachable!(),
if is_left {
JoinOperator::LeftAnti
} else {
JoinOperator::RightAnti
}
}
Some(Keyword::JOIN) => {
if is_left {
JoinOperator::LeftOuter
} else {
JoinOperator::RightOuter
}
}
Some(Keyword::JOIN) => match kw {
Keyword::LEFT => JoinOperator::LeftOuter,
Keyword::RIGHT => JoinOperator::RightOuter,
_ => unreachable!(),
},
_ => {
return Err(ParserError::ParserError(format!(
"expected OUTER, SEMI, ANTI or JOIN after {:?}",
Expand Down