nathanb9 commented on code in PR #21801:
URL: https://github.com/apache/datafusion/pull/21801#discussion_r3245109874


##########
datafusion/sql/tests/cases/plan_to_sql.rs:
##########
@@ -2848,6 +2849,253 @@ fn test_unparse_window() -> Result<()> {
     Ok(())
 }
 
+#[test]
+fn test_unparse_window_over_aggregate_without_projection() -> Result<()> {
+    let schema = Schema::new(vec![
+        Field::new("time", DataType::Int64, false),
+        Field::new("value", DataType::Float64, true),
+    ]);
+    let window_expr = Expr::WindowFunction(Box::new(WindowFunction {
+        fun: WindowFunctionDefinition::WindowUDF(row_number_udwf()),
+        params: WindowFunctionParams {
+            args: vec![],
+            partition_by: vec![],
+            order_by: vec![col("time").sort(true, true)],
+            window_frame: WindowFrame::new(None),
+            null_treatment: None,
+            distinct: false,
+            filter: None,
+        },
+    }))
+    .alias("row_idx");
+    let plan = table_scan(Some("gas"), &schema, None)?
+        .aggregate(vec![col("time")], vec![sum(col("value")).alias("sum_n")])?
+        .window(vec![window_expr])?

Review Comment:
   yea makes sense just fixed:
   * For Filter nodes, the unparser now checks for windows first when the 
dialect supports QUALIFY.
   * If there is also an aggregate underneath, aggregate aliases inside the 
QUALIFY expression are still unprojected correctly.



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to