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

[GitHub] [arrow-datafusion] berkaysynnada commented on a diff in pull request #6419: Named window support

berkaysynnada commented on code in PR #6419:
URL: https://github.com/apache/arrow-datafusion/pull/6419#discussion_r1204587073


##########
datafusion/sql/src/select.rs:
##########
@@ -70,10 +71,37 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {
         // process `where` clause
         let plan = self.plan_selection(select.selection, plan, planner_context)?;
 
+        // handle named windows before processing the projection expression
+        let mut modified_projection = select.projection.clone();
+        // If the projection is done over a named window, that window
+        // name must be defined. Otherwise, it gives an error.
+        for proj in modified_projection.iter_mut() {
+            if let SelectItem::ExprWithAlias {
+                expr: SQLExpr::Function(f),
+                alias: _,
+            } = proj
+            {
+                for NamedWindowDefinition(window_ident, window_spec) in
+                    select.named_window.iter()
+                {
+                    if let Some(WindowType::NamedWindow(ident)) = &f.over {
+                        if ident.eq(window_ident) {
+                            f.over = Some(WindowType::WindowSpec(window_spec.clone()))
+                        }
+                    }
+                }
+                // All named windows must be defined with a WindowSpec.

Review Comment:
   Thanks for the review, I agree with you. It would be better to add such a control. I think even if that multiple-defined window is not used, we should give an error, am I right?



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