Skip to content

Apache DataFusion SQL Query Engine

Update sqlparser to 0.19 (#2981)

Andrew Lamb2d23860df9e4
diff --git a/datafusion/common/Cargo.toml b/datafusion/common/Cargo.toml
index e121a55a4e..12a984b1ae 100644
--- a/datafusion/common/Cargo.toml
+++ b/datafusion/common/Cargo.toml
@@ -45,4 +45,4 @@ object_store = { version = "0.3", optional = true }
ordered-float = "3.0"
parquet = { version = "19.0.0", features = ["arrow"], optional = true }
pyo3 = { version = "0.16", optional = true }
-sqlparser = "0.18"
+sqlparser = "0.19"
diff --git a/datafusion/core/Cargo.toml b/datafusion/core/Cargo.toml
index 4385badb12..455644fe67 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.18"
+sqlparser = "0.19"
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 b91e9c470c..adfbdf10d9 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.18"
+sqlparser = "0.19"
diff --git a/datafusion/sql/Cargo.toml b/datafusion/sql/Cargo.toml
index db8720d3e4..1455597565 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.18"
+sqlparser = "0.19"
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 9bab96927d..9c4f5f027e 100644
--- a/datafusion/sql/src/planner.rs
+++ b/datafusion/sql/src/planner.rs
@@ -302,7 +302,7 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {
ctes.insert(cte_name, logical_plan);
}
}
- let plan = self.set_expr_to_plan(set_expr, alias, ctes, outer_query_schema)?;
+ let plan = self.set_expr_to_plan(*set_expr, alias, ctes, outer_query_schema)?;
let plan = self.order_by(plan, query.order_by)?;
self.limit(plan, query.offset, query.limit)
@@ -1649,7 +1649,7 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {
last_field,
fractional_seconds_precision,
}) => self.sql_interval_to_literal(
- value,
+ *value,
leading_field,
leading_precision,
last_field,
@@ -1820,13 +1820,7 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {
}),
- SQLExpr::UnaryOp { op, expr } => match (&op, expr.as_ref()) {
- // The AST for Exists does not support the NOT EXISTS case so it gets
- // wrapped in a unary NOT
- // https://github.com/sqlparser-rs/sqlparser-rs/issues/472
- (&UnaryOperator::Not, &SQLExpr::Exists(ref subquery)) => self.parse_exists_subquery(subquery, true, schema, ctes),
- _ => self.parse_sql_unary_op(op, *expr, schema, ctes)
- }
+ SQLExpr::UnaryOp { op, expr } => self.parse_sql_unary_op(op, *expr, schema, ctes),
SQLExpr::Between {
expr,
@@ -2066,7 +2060,7 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {
SQLExpr::Nested(e) => self.sql_expr_to_logical_expr(*e, schema, ctes),
- SQLExpr::Exists(subquery) => self.parse_exists_subquery(&subquery, false, schema, ctes),
+ SQLExpr::Exists{ subquery, negated } => self.parse_exists_subquery(&subquery, negated, schema, ctes),
SQLExpr::InSubquery { expr, subquery, negated } => self.parse_in_subquery(&expr, &subquery, negated, schema, ctes),
@@ -2184,7 +2178,7 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {
fn sql_interval_to_literal(
&self,
- value: String,
+ value: SQLExpr,
leading_field: Option<DateTimeField>,
leading_precision: Option<u64>,
last_field: Option<DateTimeField>,
@@ -2211,6 +2205,17 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {
)));
}
+ // Only handle string exprs for now
+ let value = match value {
+ SQLExpr::Value(Value::SingleQuotedString(s)) => s,
+ _ => {
+ return Err(DataFusionError::NotImplemented(format!(
+ "Unsupported interval argument. Expected string literal, got: {:?}",
+ value
+ )))
+ }
+ };
+
const SECONDS_PER_HOUR: f32 = 3_600_f32;
const MILLIS_PER_SECOND: f32 = 1_000_f32;