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

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

Reply via email to