Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion datafusion/common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,4 @@ ordered-float = "3.0"
parquet = { version = "19.0.0", features = ["arrow"], optional = true }
pyo3 = { version = "0.16", optional = true }
serde_json = "1.0"
sqlparser = "0.19"
sqlparser = "0.20"
2 changes: 1 addition & 1 deletion datafusion/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ pyo3 = { version = "0.16", optional = true }
rand = "0.8"
rayon = { version = "1.5", optional = true }
smallvec = { version = "1.6", features = ["union"] }
sqlparser = "0.19"
sqlparser = "0.20"
tempfile = "3"
tokio = { version = "1.0", features = ["macros", "rt", "rt-multi-thread", "sync", "fs", "parking_lot"] }
tokio-stream = "0.1"
Expand Down
35 changes: 35 additions & 0 deletions datafusion/core/tests/sql/joins.rs
Original file line number Diff line number Diff line change
Expand Up @@ -897,6 +897,41 @@ async fn inner_join_qualified_names() -> Result<()> {
Ok(())
}

#[tokio::test]
async fn nestedjoin_with_alias() -> Result<()> {
// repro case for https://github.com/apache/arrow-datafusion/issues/2867
let sql = "select * from ((select 1 as a, 2 as b) c INNER JOIN (select 1 as a, 3 as d) e on c.a = e.a) f;";
let expected = vec![
"+---+---+---+---+",
"| a | b | a | d |",
"+---+---+---+---+",
"| 1 | 2 | 1 | 3 |",
"+---+---+---+---+",
];
let ctx = SessionContext::new();
let actual = execute_to_batches(&ctx, sql).await;
assert_batches_eq!(expected, &actual);

Ok(())
}

#[tokio::test]
async fn nestedjoin_without_alias() -> Result<()> {
let sql = "select * from (select 1 as a, 2 as b) c INNER JOIN (select 1 as a, 3 as d) e on c.a = e.a;";
let expected = vec![
"+---+---+---+---+",
"| a | b | a | d |",
"+---+---+---+---+",
"| 1 | 2 | 1 | 3 |",
"+---+---+---+---+",
];
let ctx = SessionContext::new();
let actual = execute_to_batches(&ctx, sql).await;
assert_batches_eq!(expected, &actual);

Ok(())
}

#[tokio::test]
async fn issue_3002() -> Result<()> {
// repro case for https://github.com/apache/arrow-datafusion/issues/3002
Expand Down
2 changes: 1 addition & 1 deletion datafusion/expr/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ path = "src/lib.rs"
ahash = { version = "0.7", default-features = false }
arrow = { version = "19.0.0", features = ["prettyprint"] }
datafusion-common = { path = "../common", version = "10.0.0" }
sqlparser = "0.19"
sqlparser = "0.20"
2 changes: 1 addition & 1 deletion datafusion/sql/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,5 @@ arrow = { version = "19.0.0", features = ["prettyprint"] }
datafusion-common = { path = "../common", version = "10.0.0" }
datafusion-expr = { path = "../expr", version = "10.0.0" }
hashbrown = "0.12"
sqlparser = "0.19"
sqlparser = "0.20"
tokio = { version = "1.0", features = ["macros", "rt", "rt-multi-thread", "sync", "fs", "parking_lot"] }
7 changes: 5 additions & 2 deletions datafusion/sql/src/planner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -728,9 +728,12 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {
alias,
)
}
TableFactor::NestedJoin(table_with_joins) => (
TableFactor::NestedJoin {
table_with_joins,
alias,
} => (
self.plan_table_with_joins(*table_with_joins, ctes, outer_query_schema)?,
None,
alias,
),
// @todo Support TableFactory::TableFunction?
_ => {
Expand Down