From 3bd30a054dd9beffe4bef17e3a755be00eb0af11 Mon Sep 17 00:00:00 2001 From: Tim Saucer Date: Tue, 3 Dec 2024 09:05:14 -0500 Subject: [PATCH 1/2] Search default window functions if no session context was provided --- python/datafusion/functions.py | 1 + src/functions.rs | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/python/datafusion/functions.py b/python/datafusion/functions.py index 15ad8822f..f3ee5c092 100644 --- a/python/datafusion/functions.py +++ b/python/datafusion/functions.py @@ -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)) diff --git a/src/functions.rs b/src/functions.rs index e29c57f9b..5c450286f 100644 --- a/src/functions.rs +++ b/src/functions.rs @@ -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}; @@ -282,6 +283,16 @@ fn find_window_fn(name: &str, ctx: Option) -> PyResult Date: Tue, 3 Dec 2024 17:33:38 -0500 Subject: [PATCH 2/2] Check if value is None because [] don't trigger the intended behavior --- python/datafusion/dataframe.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/python/datafusion/dataframe.py b/python/datafusion/dataframe.py index e283f590e..0b38db924 100644 --- a/python/datafusion/dataframe.py +++ b/python/datafusion/dataframe.py @@ -446,14 +446,14 @@ def join( left_on = join_keys[0] right_on = join_keys[1] - if on: - if left_on or right_on: + if on is not None: + if left_on is not None or right_on is not None: raise ValueError( "`left_on` or `right_on` should not provided with `on`" ) left_on = on right_on = on - elif left_on or right_on: + elif left_on is not None or right_on is not None: if left_on is None or right_on is None: raise ValueError("`left_on` and `right_on` should both be provided.") else: