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/07/29 19:27:33 UTC

[arrow-datafusion] branch master updated: Update sqlparser to 0.19 (#2981)

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 2d23860df Update sqlparser to 0.19 (#2981)
2d23860df is described below

commit 2d23860df9e449e5ec26307d82d8a30b7e133bb6
Author: Andrew Lamb <an...@nerdnetworks.org>
AuthorDate: Fri Jul 29 15:27:28 2022 -0400

    Update sqlparser to 0.19 (#2981)
    
    * Update sqlparser to 0.19
    
    * Update planner for new API
    
    * fix overzealous cleanup
    
    * Cleanup
---
 datafusion/common/Cargo.toml  |  2 +-
 datafusion/core/Cargo.toml    |  2 +-
 datafusion/expr/Cargo.toml    |  2 +-
 datafusion/sql/Cargo.toml     |  2 +-
 datafusion/sql/src/planner.rs | 27 ++++++++++++++++-----------
 5 files changed, 20 insertions(+), 15 deletions(-)

diff --git a/datafusion/common/Cargo.toml b/datafusion/common/Cargo.toml
index e121a55a4..12a984b1a 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 4385badb1..455644fe6 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 b91e9c470..adfbdf10d 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 db8720d3e..145559756 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 9bab96927..9c4f5f027 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;