Skip to content

Commit

Permalink
feat: Allow planning window functions with window frames
Browse files Browse the repository at this point in the history
  • Loading branch information
MazterQyou committed Mar 25, 2024
1 parent 9ba8150 commit 554dac2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
6 changes: 0 additions & 6 deletions datafusion/core/src/physical_plan/planner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1479,12 +1479,6 @@ pub fn create_window_expr_with_name(
)),
})
.collect::<Result<Vec<_>>>()?;
if window_frame.is_some() {
return Err(DataFusionError::NotImplemented(
"window expression with window frame definition is not yet supported"
.to_owned(),
));
}
windows::create_window_expr(
fun,
name,
Expand Down
11 changes: 11 additions & 0 deletions datafusion/core/src/sql/planner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4872,6 +4872,17 @@ mod tests {
quick_test(sql, expected);
}

#[test]
fn window_function_with_window_frame() {
let sql =
"SELECT order_id, AVG(qty) OVER(PARTITION BY order_id ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) from orders";
let expected = "\
Projection: #orders.order_id, #AVG(orders.qty) PARTITION BY [#orders.order_id] ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW\
\n WindowAggr: windowExpr=[[AVG(#orders.qty) PARTITION BY [#orders.order_id] ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW]]\
\n TableScan: orders projection=None";
quick_test(sql, expected);
}

#[test]
fn select_typedstring() {
let sql = "SELECT date '2020-12-10' AS date FROM person";
Expand Down

0 comments on commit 554dac2

Please sign in to comment.