alamb commented on code in PR #12000: URL: https://github.com/apache/datafusion/pull/12000#discussion_r1719714295
########## datafusion/core/src/dataframe/mod.rs: ########## @@ -2869,6 +2876,39 @@ mod tests { Ok(()) } + #[tokio::test] + async fn test_window_function_with_column() -> Result<()> { + let df = test_table().await?.select_columns(&["c1", "c2", "c3"])?; + let ctx = SessionContext::new(); + let df_impl = DataFrame::new(ctx.state(), df.plan.clone()); + let func = Expr::WindowFunction(WindowFunction::new( + WindowFunctionDefinition::BuiltInWindowFunction( + BuiltInWindowFunction::RowNumber, + ), + vec![], + )) + .alias("row_num"); Review Comment: I also ran this test without the code changes and it fails like this: ``` assertion `left == right` failed left: 4 right: 5 Left: 4 Right: 5 <Click to see difference> thread 'dataframe::tests::test_window_function_with_column' panicked at datafusion/core/src/dataframe/mod.rs:2882:9: assertion `left == right` failed left: 4 right: 5 stack backtrace: 0: rust_begin_unwind at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23/library/std/src/panicking.rs:652:5 ... ``` And the output was like ``` [ "+----+----+-----+-----------------------------------------------------------------------+---+", "| c1 | c2 | c3 | ROW_NUMBER() ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING | r |", "+----+----+-----+-----------------------------------------------------------------------+---+", "| c | 2 | 1 | 1 | 1 |", "| d | 5 | -40 | 2 | 2 |", "+----+----+-----+-----------------------------------------------------------------------+---+", ] ``` ########## datafusion/core/src/dataframe/mod.rs: ########## @@ -2869,6 +2876,39 @@ mod tests { Ok(()) } + #[tokio::test] + async fn test_window_function_with_column() -> Result<()> { + let df = test_table().await?.select_columns(&["c1", "c2", "c3"])?; + let ctx = SessionContext::new(); + let df_impl = DataFrame::new(ctx.state(), df.plan.clone()); + let func = Expr::WindowFunction(WindowFunction::new( + WindowFunctionDefinition::BuiltInWindowFunction( + BuiltInWindowFunction::RowNumber, + ), + vec![], + )) + .alias("row_num"); Review Comment: I think you can use the expr fn here and make this more concise: ```suggestion let func = row_number().alias("row_num"); ``` -- 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