alamb commented on code in PR #15033:
URL: https://github.com/apache/datafusion/pull/15033#discussion_r2030129209


##########
datafusion/sql/src/select.rs:
##########
@@ -891,29 +892,42 @@ fn match_window_definitions(
     named_windows: &[NamedWindowDefinition],
 ) -> Result<()> {
     for proj in projection.iter_mut() {
-        if let SelectItem::ExprWithAlias {
-            expr: SQLExpr::Function(f),
-            alias: _,
-        }
-        | SelectItem::UnnamedExpr(SQLExpr::Function(f)) = proj
+        if let SelectItem::ExprWithAlias { expr, alias: _ }
+        | SelectItem::UnnamedExpr(expr) = proj
         {
-            for NamedWindowDefinition(window_ident, window_expr) in 
named_windows.iter() {
-                if let Some(WindowType::NamedWindow(ident)) = &f.over {
-                    if ident.eq(window_ident) {
-                        f.over = Some(match window_expr {
-                            NamedWindowExpr::NamedWindow(ident) => {
-                                WindowType::NamedWindow(ident.clone())
-                            }
-                            NamedWindowExpr::WindowSpec(spec) => {
-                                WindowType::WindowSpec(spec.clone())
+            let mut err = None;
+            visit_expressions_mut(expr, |expr| {
+                if let SQLExpr::Function(f) = expr {
+                    if let Some(WindowType::NamedWindow(_)) = &f.over {
+                        for NamedWindowDefinition(window_ident, window_expr) in
+                            named_windows
+                        {
+                            if let Some(WindowType::NamedWindow(ident)) = 
&f.over {
+                                if ident.eq(window_ident) {

Review Comment:
   Thanks @jonahgao  -- filed as 
   - https://github.com/apache/datafusion/issues/15605



-- 
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-unsubscr...@datafusion.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org
For additional commands, e-mail: github-h...@datafusion.apache.org

Reply via email to