You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "2010YOUY01 (via GitHub)" <gi...@apache.org> on 2023/06/01 18:29:28 UTC

[GitHub] [arrow-datafusion] 2010YOUY01 commented on a diff in pull request #6520: Add function name suggestion.

2010YOUY01 commented on code in PR #6520:
URL: https://github.com/apache/arrow-datafusion/pull/6520#discussion_r1213529737


##########
datafusion/sql/src/expr/function.rs:
##########
@@ -84,73 +86,88 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {
             } else {
                 WindowFrame::new(!order_by.is_empty())
             };
-            let fun = self.find_window_func(&name)?;
-            let expr = match fun {
-                WindowFunction::AggregateFunction(aggregate_fun) => {
-                    let (aggregate_fun, args) = self.aggregate_fn_to_expr(
-                        aggregate_fun,
-                        function.args,
-                        schema,
-                        planner_context,
-                    )?;
-
-                    Expr::WindowFunction(expr::WindowFunction::new(
-                        WindowFunction::AggregateFunction(aggregate_fun),
-                        args,
+            if let Ok(fun) = self.find_window_func(&name) {

Review Comment:
   The diff display on GitHub is not clear, it's just a simple refactor
   Before:
   ```rust
   if let Some(WindowType::WindowSpec(window)) = function.over.take() {
   		/* 1 */
   		let fun = self.find_window_func(&name)?;
   		/* 2 */
   		return ...;
   }
   
   /* 3 */
   
   // Return error
   Err(...)
   ```
   After:
   ```rust
   if let Some(WindowType::WindowSpec(window)) = function.over.take() {
   		/* 1 */
   		if let Ok(fun) = self.find_window_func(&name) {
   				/* 2 */
   				return ...;
   		}
   } else {
   		/* 3 */
   }
   
   // Return error
   Err(...)
   ```



-- 
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