diff --git a/python/datafusion/tests/test_dataframe.py b/python/datafusion/tests/test_dataframe.py index 5451024c7..6444d9321 100644 --- a/python/datafusion/tests/test_dataframe.py +++ b/python/datafusion/tests/test_dataframe.py @@ -295,13 +295,11 @@ def test_distinct(): order_by=[f.order_by(column("b"))] ), [1, 1, 1], - marks=pytest.mark.xfail, ), pytest.param( "last_value", f.window("last_value", [column("b")], order_by=[f.order_by(column("b"))]), [4, 5, 6], - marks=pytest.mark.xfail, ), pytest.param( "2nd_value", diff --git a/src/functions.rs b/src/functions.rs index c9a48e16c..8dc72de34 100644 --- a/src/functions.rs +++ b/src/functions.rs @@ -613,13 +613,21 @@ fn case(expr: PyExpr) -> PyResult { /// Helper function to find the appropriate window function. /// /// Search procedure: +/// 1) Search built in window functions, which are being deprecated. /// 1) If a session context is provided: /// 1) search User Defined Aggregate Functions (UDAFs) -/// 2) search registered window functions -/// 3) search registered aggregate functions -/// 2) If no function has been found, search default aggregate functions. -/// 3) Lastly, as a fall back attempt, search built in window functions, which are being deprecated. +/// 1) search registered window functions +/// 1) search registered aggregate functions +/// 1) If no function has been found, search default aggregate functions. +/// +/// NOTE: we search the built-ins first because the `UDAF` versions currently do not have the same behavior. fn find_window_fn(name: &str, ctx: Option) -> PyResult { + // search built in window functions (soon to be deprecated) + let df_window_func = find_df_window_func(name); + if let Some(df_window_func) = df_window_func { + return Ok(df_window_func); + } + if let Some(ctx) = ctx { // search UDAFs let udaf = ctx @@ -665,12 +673,6 @@ fn find_window_fn(name: &str, ctx: Option) -> PyResult