Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(query): add check window frame #17316

Merged
merged 6 commits into from
Jan 21, 2025
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
15 changes: 15 additions & 0 deletions src/query/sql/src/planner/semantic/type_check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1193,6 +1193,21 @@ impl<'a> TypeChecker<'a> {

let frame =
self.resolve_window_frame(span, &func, &mut order_by, spec.window_frame.clone())?;

if matches!(&frame.start_bound, WindowFuncFrameBound::Following(None)) {
return Err(ErrorCode::SemanticError(
"Frame start cannot be UNBOUNDED FOLLOWING".to_string(),
)
.set_span(span));
}

if matches!(&frame.end_bound, WindowFuncFrameBound::Preceding(None)) {
return Err(ErrorCode::SemanticError(
"Frame end cannot be UNBOUNDED PRECEDING".to_string(),
)
.set_span(span));
}

let data_type = func.return_type();
let window_func = WindowFunc {
span,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
statement ok
CREATE DATABASE IF NOT EXISTS test_window_basic


statement error 1065
SELECT last_value(number) OVER (ORDER BY number ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED PRECEDING) FROM numbers(1);

statement error 1065
SELECT last_value(number) OVER (ORDER BY number RANGE BETWEEN UNBOUNDED FOLLOWING AND UNBOUNDED FOLLOWING) FROM numbers(1);

statement ok
USE test_window_basic

Expand Down
Loading