Skip to content

Commit

Permalink
fix: aggregate and window function as the argument of unnest return u…
Browse files Browse the repository at this point in the history
…nable to get field named (databendlabs#14233)

fix unnest bug

Co-authored-by: jw <[email protected]>
  • Loading branch information
Freejww and jw authored Jan 5, 2024
1 parent 3759207 commit 89d6c91
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/query/sql/src/planner/semantic/type_check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1399,6 +1399,15 @@ impl<'a> TypeChecker<'a> {
)
.set_span(span));
}
if matches!(
self.bind_context.expr_context,
ExprContext::InSetReturningFunction
) {
return Err(ErrorCode::SemanticError(
"window functions can not be used in set-returning function".to_string(),
)
.set_span(span));
}
// try to resolve window function without arguments first
if let Ok(window_func) = WindowFuncType::from_name(func_name) {
return Ok(window_func);
Expand Down Expand Up @@ -1633,6 +1642,15 @@ impl<'a> TypeChecker<'a> {
)
.set_span(span));
}
if matches!(
self.bind_context.expr_context,
ExprContext::InSetReturningFunction
) {
return Err(ErrorCode::SemanticError(
"aggregate functions can not be used in set-returning function".to_string(),
)
.set_span(span));
}
if self.in_aggregate_function {
if self.in_window_function {
// The aggregate function can be in window function call,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,15 @@ query T
select unnest(parse_json('"a"'))
----

statement error 1065
select unnest(max(11))

statement error 1065
select unnest(min(11),max(12))

statement error 1065
select unnest(first_value('aa') OVER (PARTITION BY 'bb'))

statement ok
set max_block_size = 65535;

Expand Down

0 comments on commit 89d6c91

Please sign in to comment.