You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2022/02/09 14:22:57 UTC

[GitHub] [arrow-datafusion] alamb opened a new pull request #1796: Update to sqlparser 0.14

alamb opened a new pull request #1796:
URL: https://github.com/apache/arrow-datafusion/pull/1796


   Draft until sqlparser 0.14 is actually released
   
   # Which issue does this PR close?
   
   N/A
    # Rationale for this change
   
   A new version of sqlparser is about to be released, and this PR serves as potential QA for this effort
   
   
   # What changes are included in this PR?
   1. Update sqlparser version
   2. update datafusion sqlparser for new changes
   
   
   # Are there any user-facing changes?
   New dependency and some new SQL syntax support


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow-datafusion] alamb commented on pull request #1796: Update to sqlparser 0.14

Posted by GitBox <gi...@apache.org>.
alamb commented on pull request #1796:
URL: https://github.com/apache/arrow-datafusion/pull/1796#issuecomment-1036509780


   Thanks @xudong963 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow-datafusion] alamb commented on pull request #1796: Update to sqlparser 0.14

Posted by GitBox <gi...@apache.org>.
alamb commented on pull request #1796:
URL: https://github.com/apache/arrow-datafusion/pull/1796#issuecomment-1036101312


   I think it might be nice to update to latest sqlparser before the 7.0.0 release


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow-datafusion] alamb merged pull request #1796: Update to sqlparser 0.14

Posted by GitBox <gi...@apache.org>.
alamb merged pull request #1796:
URL: https://github.com/apache/arrow-datafusion/pull/1796


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow-datafusion] alamb commented on a change in pull request #1796: Update to sqlparser 0.14

Posted by GitBox <gi...@apache.org>.
alamb commented on a change in pull request #1796:
URL: https://github.com/apache/arrow-datafusion/pull/1796#discussion_r802714477



##########
File path: datafusion/src/sql/planner.rs
##########
@@ -1241,11 +1246,20 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {
         sql: &FunctionArg,
         schema: &DFSchema,
     ) -> Result<Expr> {
-        match sql {
-            FunctionArg::Named { name: _, arg } => {
-                self.sql_expr_to_logical_expr(arg, schema)
+        let arg: &FunctionArgExpr = match sql {
+            FunctionArg::Named { name: _, arg } => arg,
+            FunctionArg::Unnamed(arg) => arg,
+        };
+
+        match arg {

Review comment:
       Needed due to https://github.com/sqlparser-rs/sqlparser-rs/pull/378 from @panarch  (so we don't allow crazy stuff like `SELECT * + * from foo` 👍 




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow-datafusion] alamb commented on a change in pull request #1796: Update to sqlparser 0.14

Posted by GitBox <gi...@apache.org>.
alamb commented on a change in pull request #1796:
URL: https://github.com/apache/arrow-datafusion/pull/1796#discussion_r802716290



##########
File path: datafusion/src/sql/planner.rs
##########
@@ -85,30 +86,40 @@ pub struct SqlToRel<'a, S: ContextProvider> {
     schema_provider: &'a S,
 }
 
-fn plan_key(key: Value) -> ScalarValue {
-    match key {
-        Value::Number(s, _) => ScalarValue::Int64(Some(s.parse().unwrap())),
-        Value::SingleQuotedString(s) => ScalarValue::Utf8(Some(s)),
-        _ => unreachable!(),
-    }
+fn plan_key(key: SQLExpr) -> Result<ScalarValue> {
+    let scalar = match key {
+        SQLExpr::Value(Value::Number(s, _)) => {
+            ScalarValue::Int64(Some(s.parse().unwrap()))
+        }
+        SQLExpr::Value(Value::SingleQuotedString(s)) => ScalarValue::Utf8(Some(s)),
+        _ => {
+            return Err(DataFusionError::SQL(ParserError(format!(
+                "Unsuported index key expression: {}",
+                key
+            ))))
+        }
+    };
+
+    Ok(scalar)
 }
 
-#[allow(clippy::branches_sharing_code)]
-fn plan_indexed(expr: Expr, mut keys: Vec<Value>) -> Expr {
-    if keys.len() == 1 {
-        let key = keys.pop().unwrap();
-        Expr::GetIndexedField {
-            expr: Box::new(expr),
-            key: plan_key(key),
-        }
+fn plan_indexed(expr: Expr, mut keys: Vec<SQLExpr>) -> Result<Expr> {

Review comment:
       I had to change this code anyways to handle arbitrary expressions due to https://github.com/sqlparser-rs/sqlparser-rs/pull/382 so I took the time to remove the clippy warning too 




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org