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

This commit is contained in:
Andrew Lamb 2022-11-30 13:25:02 -05:00 committed by GitHub
parent b17c44a64a
commit bd35273789
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -4838,6 +4838,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,
@ -4847,33 +4848,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 {:?}",