You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by al...@apache.org on 2022/08/08 11:59:09 UTC
[arrow-datafusion] branch master updated: Update sql parser to v0.20.0 (#3072)
This is an automated email from the ASF dual-hosted git repository.
alamb pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow-datafusion.git
The following commit(s) were added to refs/heads/master by this push:
new acd1f40e7 Update sql parser to v0.20.0 (#3072)
acd1f40e7 is described below
commit acd1f40e7b5ba5d2100a9147785d28079bea48e6
Author: Wei-Ting Kuo <wa...@gmail.com>
AuthorDate: Mon Aug 8 19:59:05 2022 +0800
Update sql parser to v0.20.0 (#3072)
* add test case nestedjoin_with_alias (issue2867)
* upgrade sqlparser to 0.20
* add test case for nestedjoin without alias
---
datafusion/common/Cargo.toml | 2 +-
datafusion/core/Cargo.toml | 2 +-
datafusion/core/tests/sql/joins.rs | 35 +++++++++++++++++++++++++++++++++++
datafusion/expr/Cargo.toml | 2 +-
datafusion/sql/Cargo.toml | 2 +-
datafusion/sql/src/planner.rs | 7 +++++--
6 files changed, 44 insertions(+), 6 deletions(-)
diff --git a/datafusion/common/Cargo.toml b/datafusion/common/Cargo.toml
index 33d6af087..9bab66ada 100644
--- a/datafusion/common/Cargo.toml
+++ b/datafusion/common/Cargo.toml
@@ -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"
diff --git a/datafusion/core/Cargo.toml b/datafusion/core/Cargo.toml
index 073b951ff..a76b2fc49 100644
--- a/datafusion/core/Cargo.toml
+++ b/datafusion/core/Cargo.toml
@@ -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"
diff --git a/datafusion/core/tests/sql/joins.rs b/datafusion/core/tests/sql/joins.rs
index d1632277a..19de20d61 100644
--- a/datafusion/core/tests/sql/joins.rs
+++ b/datafusion/core/tests/sql/joins.rs
@@ -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
diff --git a/datafusion/expr/Cargo.toml b/datafusion/expr/Cargo.toml
index e99a24c32..923015ae5 100644
--- a/datafusion/expr/Cargo.toml
+++ b/datafusion/expr/Cargo.toml
@@ -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"
diff --git a/datafusion/sql/Cargo.toml b/datafusion/sql/Cargo.toml
index 760a58587..17e658399 100644
--- a/datafusion/sql/Cargo.toml
+++ b/datafusion/sql/Cargo.toml
@@ -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"] }
diff --git a/datafusion/sql/src/planner.rs b/datafusion/sql/src/planner.rs
index d93076fbd..6c3e80e32 100644
--- a/datafusion/sql/src/planner.rs
+++ b/datafusion/sql/src/planner.rs
@@ -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?
_ => {