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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]