Skip to content

Commit 50cac4e

Browse files
provides workaround for half-migrated UDAF sum
Ref #730
1 parent faa26b2 commit 50cac4e

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

examples/tpch/_tests.py

-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ def check_q17(df):
7474
("q10_returned_item_reporting", "q10"),
7575
pytest.param(
7676
"q11_important_stock_identification", "q11",
77-
marks=pytest.mark.xfail # https://github.com/apache/datafusion-python/issues/730
7877
),
7978
("q12_ship_mode_order_priority", "q12"),
8079
("q13_customer_distribution", "q13"),

src/functions.rs

+13-7
Original file line numberDiff line numberDiff line change
@@ -320,14 +320,20 @@ fn window(
320320
window_frame: Option<PyWindowFrame>,
321321
ctx: Option<PySessionContext>,
322322
) -> PyResult<PyExpr> {
323-
let fun = find_df_window_func(name).or_else(|| {
324-
ctx.and_then(|ctx| {
325-
ctx.ctx
326-
.udaf(name)
327-
.map(WindowFunctionDefinition::AggregateUDF)
328-
.ok()
323+
// workaround for https://github.com/apache/datafusion-python/issues/730
324+
let fun = if name == "sum" {
325+
let sum_udf = functions_aggregate::sum::sum_udaf();
326+
Some(WindowFunctionDefinition::AggregateUDF(sum_udf))
327+
} else {
328+
find_df_window_func(name).or_else(|| {
329+
ctx.and_then(|ctx| {
330+
ctx.ctx
331+
.udaf(name)
332+
.map(WindowFunctionDefinition::AggregateUDF)
333+
.ok()
334+
})
329335
})
330-
});
336+
};
331337
if fun.is_none() {
332338
return Err(DataFusionError::Common("window function not found".to_string()).into());
333339
}

0 commit comments

Comments
 (0)