mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-09-01 03:37:21 +00:00
Properly handle mixed implicit and explicit joins
Parse a query like SELECT * FROM a NATURAL JOIN b, c NATURAL JOIN d as the SQL specification requires, i.e.: from: [ TableReference { relation: TableFactor::Table("a"), joins: [Join { relation: TableFactor::Table("b"), join_operator: JoinOperator::Natural, }] }, TableReference { relation: TableFactor::Table("c"), joins: [Join { relation: TableFactor::Table("d"), join_operator: JoinOperator::Natural, }] } ] Previously we were parsing such queries as relation: TableFactor::Table("a"), joins: [ Join { relation: TableFactor::Table("b"), join_operator: JoinOperator::Natural, }, Join { relation: TableFactor::Table("c"), join_operator: JoinOperator::Implicit, }, Join { relation: TableFactor::Table("d"), join_operator: JoinOperator::Natural, }, ] which did not make the join hierarchy clear.
This commit is contained in:
parent
518c8833d2
commit
b841dccc2c
6 changed files with 219 additions and 164 deletions
|
@ -109,9 +109,13 @@ pub fn all_dialects() -> TestedDialects {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn only<T>(v: &[T]) -> &T {
|
||||
assert_eq!(1, v.len());
|
||||
v.first().unwrap()
|
||||
pub fn only<T>(v: impl IntoIterator<Item = T>) -> T {
|
||||
let mut iter = v.into_iter();
|
||||
if let (Some(item), None) = (iter.next(), iter.next()) {
|
||||
item
|
||||
} else {
|
||||
panic!("only called on collection without exactly one item")
|
||||
}
|
||||
}
|
||||
|
||||
pub fn expr_from_projection(item: &SQLSelectItem) -> &ASTNode {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue