This is an automated email from the ASF dual-hosted git repository.

alamb pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow-datafusion.git


The following commit(s) were added to refs/heads/main by this push:
     new 44936efaeb Minor: remove `..` pattern matching in sql planner (#9531)
44936efaeb is described below

commit 44936efaeb41d5608953252d40db24cb0cce46b3
Author: Andrew Lamb <[email protected]>
AuthorDate: Mon Mar 11 07:15:45 2024 -0400

    Minor: remove `..` pattern matching in sql planner (#9531)
---
 datafusion/sql/src/expr/mod.rs | 42 +++++++++++++++++++++++++++++-------------
 1 file changed, 29 insertions(+), 13 deletions(-)

diff --git a/datafusion/sql/src/expr/mod.rs b/datafusion/sql/src/expr/mod.rs
index e838a4cafb..daca470424 100644
--- a/datafusion/sql/src/expr/mod.rs
+++ b/datafusion/sql/src/expr/mod.rs
@@ -271,8 +271,14 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {
             ),
 
             SQLExpr::Cast {
-                expr, data_type, ..
+                expr,
+                data_type,
+                format,
             } => {
+                if let Some(format) = format {
+                    return not_impl_err!("CAST with format is not supported: 
{format}");
+                }
+
                 let dt = self.convert_data_type(&data_type)?;
                 let expr =
                     self.sql_expr_to_logical_expr(*expr, schema, 
planner_context)?;
@@ -295,15 +301,23 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {
             }
 
             SQLExpr::TryCast {
-                expr, data_type, ..
-            } => Ok(Expr::TryCast(TryCast::new(
-                Box::new(self.sql_expr_to_logical_expr(
-                    *expr,
-                    schema,
-                    planner_context,
-                )?),
-                self.convert_data_type(&data_type)?,
-            ))),
+                expr,
+                data_type,
+                format,
+            } => {
+                if let Some(format) = format {
+                    return not_impl_err!("CAST with format is not supported: 
{format}");
+                }
+
+                Ok(Expr::TryCast(TryCast::new(
+                    Box::new(self.sql_expr_to_logical_expr(
+                        *expr,
+                        schema,
+                        planner_context,
+                    )?),
+                    self.convert_data_type(&data_type)?,
+                )))
+            }
 
             SQLExpr::TypedString { data_type, value } => 
Ok(Expr::Cast(Cast::new(
                 Box::new(lit(value)),
@@ -478,7 +492,6 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {
                 trim_where,
                 trim_what,
                 trim_characters,
-                ..
             } => self.sql_trim_to_expr(
                 *expr,
                 trim_where,
@@ -801,7 +814,7 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {
                 distinct,
                 order_by,
                 null_treatment,
-                ..
+                filter: None, // filter is passed in
             }) => Ok(Expr::AggregateFunction(expr::AggregateFunction::new(
                 fun,
                 args,
@@ -814,7 +827,10 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {
                 order_by,
                 null_treatment,
             ))),
-            _ => plan_err!(
+            Expr::AggregateFunction(..) => {
+                internal_err!("Expected null filter clause in aggregate 
function")
+            }
+            _ => internal_err!(
                 "AggregateExpressionWithFilter expression was not an 
AggregateFunction"
             ),
         }

Reply via email to