mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-07-07 17:04:59 +00:00
Add support for MySQL's STRAIGHT_JOIN join operator. (#1802)
Co-authored-by: Roman Borschel <roman@cluvio.com>
This commit is contained in:
parent
cfd8951452
commit
67c3be075e
5 changed files with 20 additions and 0 deletions
|
@ -2157,6 +2157,9 @@ impl fmt::Display for Join {
|
|||
self.relation,
|
||||
suffix(constraint)
|
||||
),
|
||||
JoinOperator::StraightJoin(constraint) => {
|
||||
write!(f, " STRAIGHT_JOIN {}{}", self.relation, suffix(constraint))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2197,6 +2200,10 @@ pub enum JoinOperator {
|
|||
match_condition: Expr,
|
||||
constraint: JoinConstraint,
|
||||
},
|
||||
/// STRAIGHT_JOIN (non-standard)
|
||||
///
|
||||
/// See <https://dev.mysql.com/doc/refman/8.4/en/join.html>.
|
||||
StraightJoin(JoinConstraint),
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, PartialOrd, Eq, Ord, Hash)]
|
||||
|
|
|
@ -2128,6 +2128,7 @@ impl Spanned for JoinOperator {
|
|||
} => match_condition.span().union(&constraint.span()),
|
||||
JoinOperator::Anti(join_constraint) => join_constraint.span(),
|
||||
JoinOperator::Semi(join_constraint) => join_constraint.span(),
|
||||
JoinOperator::StraightJoin(join_constraint) => join_constraint.span(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -840,6 +840,7 @@ define_keywords!(
|
|||
STORAGE_INTEGRATION,
|
||||
STORAGE_SERIALIZATION_POLICY,
|
||||
STORED,
|
||||
STRAIGHT_JOIN,
|
||||
STRICT,
|
||||
STRING,
|
||||
STRUCT,
|
||||
|
|
|
@ -11826,6 +11826,10 @@ impl<'a> Parser<'a> {
|
|||
Keyword::OUTER => {
|
||||
return self.expected("LEFT, RIGHT, or FULL", self.peek_token());
|
||||
}
|
||||
Keyword::STRAIGHT_JOIN => {
|
||||
let _ = self.next_token(); // consume STRAIGHT_JOIN
|
||||
JoinOperator::StraightJoin
|
||||
}
|
||||
_ if natural => {
|
||||
return self.expected("a join type after NATURAL", self.peek_token());
|
||||
}
|
||||
|
|
|
@ -3587,3 +3587,10 @@ fn test_variable_assignment_using_colon_equal() {
|
|||
_ => panic!("Unexpected statement {stmt}"),
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_straight_join() {
|
||||
mysql().verified_stmt(
|
||||
"SELECT a.*, b.* FROM table_a AS a STRAIGHT_JOIN table_b AS b ON a.b_id = b.id",
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue