mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-08-30 18:57:21 +00:00
Cleanup: avoid using unreachable!
when parsing semi/anti join (#738)
This commit is contained in:
parent
b17c44a64a
commit
bd35273789
1 changed files with 20 additions and 17 deletions
|
@ -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 {:?}",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue