Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions python/datafusion/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,7 @@ def window(
partition_by = expr_list_to_raw_expr_list(partition_by)
order_by_raw = sort_list_to_raw_sort_list(order_by)
window_frame = window_frame.window_frame if window_frame is not None else None
ctx = ctx.ctx if ctx is not None else None
return Expr(f.window(name, args, partition_by, order_by_raw, window_frame, ctx))


Expand Down
11 changes: 11 additions & 0 deletions src/functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
// under the License.

use datafusion::functions_aggregate::all_default_aggregate_functions;
use datafusion::functions_window::all_default_window_functions;
use datafusion::logical_expr::ExprFunctionExt;
use datafusion::logical_expr::WindowFrame;
use pyo3::{prelude::*, wrap_pyfunction};
Expand Down Expand Up @@ -282,6 +283,16 @@ fn find_window_fn(name: &str, ctx: Option<PySessionContext>) -> PyResult<WindowF
return Ok(agg_fn);
}

// search default window functions
let window_fn = all_default_window_functions()
.iter()
.find(|v| v.name() == name || v.aliases().contains(&name.to_string()))
.map(|f| WindowFunctionDefinition::WindowUDF(f.clone()));

if let Some(window_fn) = window_fn {
return Ok(window_fn);
}

Err(DataFusionError::Common(format!("window function `{name}` not found")).into())
}

Expand Down
Loading