Skip to content

Commit 7d31d40

Browse files
committed
fix: Allow unbounded window frames
1 parent 94ddd00 commit 7d31d40

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

Diff for: datafusion/core/src/physical_plan/planner.rs

+13-6
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ use arrow::{compute::can_cast_types, datatypes::DataType};
6969
use async_trait::async_trait;
7070
use datafusion_common::OuterQueryCursor;
7171
use datafusion_expr::expr_fn::binary_expr;
72+
use datafusion_expr::WindowFrameBound;
7273
use datafusion_physical_expr::expressions::{any, OuterColumn};
7374
use futures::future::BoxFuture;
7475
use futures::{FutureExt, StreamExt, TryStreamExt};
@@ -1433,12 +1434,18 @@ pub fn create_window_expr_with_name(
14331434
)),
14341435
})
14351436
.collect::<Result<Vec<_>>>()?;
1436-
if window_frame.is_some() {
1437-
return Err(DataFusionError::NotImplemented(
1438-
"window expression with window frame definition is not yet supported"
1439-
.to_owned(),
1440-
));
1441-
}
1437+
let window_frame = match window_frame {
1438+
Some(window_frame) => match (&window_frame.start_bound, &window_frame.end_bound) {
1439+
(WindowFrameBound::Preceding(None), WindowFrameBound::CurrentRow)
1440+
| (WindowFrameBound::Preceding(None), WindowFrameBound::Following(None))
1441+
| (WindowFrameBound::CurrentRow, WindowFrameBound::Following(None)) => &None,
1442+
(_, _) => return Err(DataFusionError::NotImplemented(
1443+
"window expression with window frame definition is not yet supported"
1444+
.to_owned(),
1445+
)),
1446+
},
1447+
None => &None,
1448+
};
14421449
windows::create_window_expr(
14431450
fun,
14441451
name,

0 commit comments

Comments
 (0)