Skip to content

Apache DataFusion SQL Query Engine

Update sqlparser to 0.24.0 (#3675)

Andrew Lambf706902bcb5e
diff --git a/datafusion/common/Cargo.toml b/datafusion/common/Cargo.toml
index c2c20f43cd..48bc61f536 100644
--- a/datafusion/common/Cargo.toml
+++ b/datafusion/common/Cargo.toml
@@ -46,4 +46,4 @@ object_store = { version = "0.5.0", default-features = false, optional = true }
ordered-float = "3.0"
parquet = { version = "23.0.0", default-features = false, optional = true }
pyo3 = { version = "0.17.1", optional = true }
-sqlparser = "0.23"
+sqlparser = "0.24"
diff --git a/datafusion/core/Cargo.toml b/datafusion/core/Cargo.toml
index f5f4350b07..1e338c5d10 100644
--- a/datafusion/core/Cargo.toml
+++ b/datafusion/core/Cargo.toml
@@ -85,7 +85,7 @@ pyo3 = { version = "0.17.1", optional = true }
rand = "0.8"
rayon = { version = "1.5", optional = true }
smallvec = { version = "1.6", features = ["union"] }
-sqlparser = "0.23"
+sqlparser = "0.24"
tempfile = "3"
tokio = { version = "1.0", features = ["macros", "rt", "rt-multi-thread", "sync", "fs", "parking_lot"] }
tokio-stream = "0.1"
diff --git a/datafusion/expr/Cargo.toml b/datafusion/expr/Cargo.toml
index 101035a2ee..e0b8e2d525 100644
--- a/datafusion/expr/Cargo.toml
+++ b/datafusion/expr/Cargo.toml
@@ -38,4 +38,4 @@ path = "src/lib.rs"
ahash = { version = "0.8", default-features = false, features = ["runtime-rng"] }
arrow = { version = "23.0.0", default-features = false }
datafusion-common = { path = "../common", version = "12.0.0" }
-sqlparser = "0.23"
+sqlparser = "0.24"
diff --git a/datafusion/sql/Cargo.toml b/datafusion/sql/Cargo.toml
index 769d74a0c9..cf057a562a 100644
--- a/datafusion/sql/Cargo.toml
+++ b/datafusion/sql/Cargo.toml
@@ -40,4 +40,4 @@ unicode_expressions = []
arrow = { version = "23.0.0", default-features = false }
datafusion-common = { path = "../common", version = "12.0.0" }
datafusion-expr = { path = "../expr", version = "12.0.0" }
-sqlparser = "0.23"
+sqlparser = "0.24"
diff --git a/datafusion/sql/src/planner.rs b/datafusion/sql/src/planner.rs
index b6a6d584a0..77e77444c3 100644
--- a/datafusion/sql/src/planner.rs
+++ b/datafusion/sql/src/planner.rs
@@ -152,6 +152,7 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {
verbose,
statement,
analyze,
+ format: _,
describe_alias: _,
} => self.explain_statement_to_plan(verbose, analyze, *statement),
Statement::Query(query) => self.query_to_plan(*query, &mut HashMap::new()),
@@ -364,7 +365,7 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {
}
// create logical plan & pass backreferencing CTEs
let logical_plan = self.query_to_plan_with_alias(
- cte.query,
+ *cte.query,
Some(cte_name.clone()),
&mut ctes.clone(),
outer_query_schema,
@@ -1720,13 +1721,15 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {
],
}),
- SQLExpr::Value(Value::Interval {
+ SQLExpr::Array(arr) => self.sql_array_literal(arr.elem, schema),
+
+ SQLExpr::Interval {
value,
leading_field,
leading_precision,
last_field,
fractional_seconds_precision,
- }) => self.sql_interval_to_literal(
+ } => self.sql_interval_to_expr(
*value,
leading_field,
leading_precision,
@@ -1734,8 +1737,6 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {
fractional_seconds_precision,
),
- SQLExpr::Array(arr) => self.sql_array_literal(arr.elem, schema),
-
SQLExpr::Identifier(id) => {
if id.value.starts_with('@') {
// TODO: figure out if ScalarVariables should be insensitive.
@@ -2325,7 +2326,7 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {
Ok((fun, args))
}
- fn sql_interval_to_literal(
+ fn sql_interval_to_expr(
&self,
value: SQLExpr,
leading_field: Option<DateTimeField>,
@@ -2697,7 +2698,7 @@ pub fn convert_simple_data_type(sql_type: &SQLDataType) -> Result<DataType> {
SQLDataType::UnsignedBigInt(_) => Ok(DataType::UInt64),
SQLDataType::Float(_) => Ok(DataType::Float32),
SQLDataType::Real => Ok(DataType::Float32),
- SQLDataType::Double => Ok(DataType::Float64),
+ SQLDataType::Double | SQLDataType::DoublePrecision => Ok(DataType::Float64),
SQLDataType::Char(_)
| SQLDataType::Varchar(_)
| SQLDataType::Text
@@ -2726,6 +2727,8 @@ pub fn convert_simple_data_type(sql_type: &SQLDataType) -> Result<DataType> {
| SQLDataType::Array(_)
| SQLDataType::Enum(_)
| SQLDataType::Set(_)
+ | SQLDataType::MediumInt(_)
+ | SQLDataType::UnsignedMediumInt(_)
| SQLDataType::Clob(_) => Err(DataFusionError::NotImplemented(format!(
"Unsupported SQL type {:?}",
sql_type