alamb commented on code in PR #4779:
URL: https://github.com/apache/arrow-datafusion/pull/4779#discussion_r1059653543


##########
datafusion/sql/src/planner.rs:
##########
@@ -2193,159 +2038,11 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {
                 ))
             }
 
-            SQLExpr::Trim { expr, trim_where, trim_what } => {
-                let fun = match trim_where {
-                    Some(TrimWhereField::Leading) => {
-                        BuiltinScalarFunction::Ltrim
-                    }
-                    Some(TrimWhereField::Trailing) => {
-                        BuiltinScalarFunction::Rtrim
-                    }
-                    Some(TrimWhereField::Both) => {
-                        BuiltinScalarFunction::Btrim
-                    }
-                    None => BuiltinScalarFunction::Trim
-                };
-                let arg = self.sql_expr_to_logical_expr(*expr, schema, 
planner_context)?;
-                let args = match trim_what {
-                    Some(to_trim) => {
-                        let to_trim = self.sql_expr_to_logical_expr(*to_trim, 
schema, planner_context)?;
-                        vec![arg, to_trim]
-                    }
-                    None => vec![arg],
-                };
-                Ok(Expr::ScalarFunction { fun, args })
-            }
+            SQLExpr::Trim { expr, trim_where, trim_what } => 
self.sql_trim_to_expr(expr, trim_where, trim_what, schema, planner_context),
 
-            SQLExpr::AggregateExpressionWithFilter { expr, filter } => {
-                match self.sql_expr_to_logical_expr(*expr, schema, 
planner_context)? {
-                    Expr::AggregateFunction(expr::AggregateFunction {
-                        fun, args, distinct, ..
-                    }) => 
Ok(Expr::AggregateFunction(expr::AggregateFunction::new( fun, args, distinct, 
Some(Box::new(self.sql_expr_to_logical_expr(*filter, schema, 
planner_context)?)) ))),
-                    _ => 
Err(DataFusionError::Internal("AggregateExpressionWithFilter expression was not 
an AggregateFunction".to_string()))
-                }
-            }
+            SQLExpr::AggregateExpressionWithFilter { expr, filter } => 
self.sql_agg_with_filter_to_expr(expr, filter, schema, planner_context),
 
-            SQLExpr::Function(mut function) => {
-                let name = if function.name.0.len() > 1 {

Review Comment:
   I think the expanded handling of `SQLExpr::Function` is likely the thing 
that resulted in significantly larger stacks and thus overflows



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to