mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-12-23 11:12:51 +00:00
Allow plain JOIN without turning it into INNER (#1692)
This commit is contained in:
parent
784605c913
commit
252fdbab82
8 changed files with 42 additions and 16 deletions
|
|
@ -2038,13 +2038,20 @@ impl fmt::Display for Join {
|
|||
}
|
||||
|
||||
match &self.join_operator {
|
||||
JoinOperator::Inner(constraint) => write!(
|
||||
JoinOperator::Join(constraint) => write!(
|
||||
f,
|
||||
" {}JOIN {}{}",
|
||||
prefix(constraint),
|
||||
self.relation,
|
||||
suffix(constraint)
|
||||
),
|
||||
JoinOperator::Inner(constraint) => write!(
|
||||
f,
|
||||
" {}INNER JOIN {}{}",
|
||||
prefix(constraint),
|
||||
self.relation,
|
||||
suffix(constraint)
|
||||
),
|
||||
JoinOperator::LeftOuter(constraint) => write!(
|
||||
f,
|
||||
" {}LEFT JOIN {}{}",
|
||||
|
|
@ -2128,6 +2135,7 @@ impl fmt::Display for Join {
|
|||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
#[cfg_attr(feature = "visitor", derive(Visit, VisitMut))]
|
||||
pub enum JoinOperator {
|
||||
Join(JoinConstraint),
|
||||
Inner(JoinConstraint),
|
||||
LeftOuter(JoinConstraint),
|
||||
RightOuter(JoinConstraint),
|
||||
|
|
|
|||
|
|
@ -2001,6 +2001,7 @@ impl Spanned for Join {
|
|||
impl Spanned for JoinOperator {
|
||||
fn span(&self) -> Span {
|
||||
match self {
|
||||
JoinOperator::Join(join_constraint) => join_constraint.span(),
|
||||
JoinOperator::Inner(join_constraint) => join_constraint.span(),
|
||||
JoinOperator::LeftOuter(join_constraint) => join_constraint.span(),
|
||||
JoinOperator::RightOuter(join_constraint) => join_constraint.span(),
|
||||
|
|
|
|||
|
|
@ -11000,9 +11000,13 @@ impl<'a> Parser<'a> {
|
|||
|
||||
let join_operator_type = match peek_keyword {
|
||||
Keyword::INNER | Keyword::JOIN => {
|
||||
let _ = self.parse_keyword(Keyword::INNER); // [ INNER ]
|
||||
let inner = self.parse_keyword(Keyword::INNER); // [ INNER ]
|
||||
self.expect_keyword_is(Keyword::JOIN)?;
|
||||
JoinOperator::Inner
|
||||
if inner {
|
||||
JoinOperator::Inner
|
||||
} else {
|
||||
JoinOperator::Join
|
||||
}
|
||||
}
|
||||
kw @ Keyword::LEFT | kw @ Keyword::RIGHT => {
|
||||
let _ = self.next_token(); // consume LEFT/RIGHT
|
||||
|
|
|
|||
|
|
@ -403,7 +403,7 @@ pub fn join(relation: TableFactor) -> Join {
|
|||
Join {
|
||||
relation,
|
||||
global: false,
|
||||
join_operator: JoinOperator::Inner(JoinConstraint::Natural),
|
||||
join_operator: JoinOperator::Join(JoinConstraint::Natural),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue