Skip to content

Commit ceafe0b

Browse files
committed
fix: allow aggregate functions in having outside from step
1 parent b387d4f commit ceafe0b

2 files changed

Lines changed: 11 additions & 6 deletions

File tree

src/binder/expr.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -564,11 +564,6 @@ impl<'a, T: Transaction, A: AsRef<[(&'static str, DataValue)]>> Binder<'a, '_, T
564564
}
565565

566566
fn bind_function(&mut self, func: &Function) -> Result<ScalarExpression, DatabaseError> {
567-
if !matches!(self.context.step_now(), QueryBindStep::From) {
568-
return Err(DatabaseError::UnsupportedStmt(
569-
"`TableFunction` cannot bind in non-From step".to_string(),
570-
));
571-
}
572567
let (func_args, is_distinct) = match &func.args {
573568
FunctionArguments::List(args) => (
574569
args.args.as_slice(),
@@ -749,6 +744,11 @@ impl<'a, T: Transaction, A: AsRef<[(&'static str, DataValue)]>> Binder<'a, '_, T
749744
}));
750745
}
751746
if let Some(function) = self.context.table_functions.get(&summary) {
747+
if !matches!(self.context.step_now(), QueryBindStep::From) {
748+
return Err(DatabaseError::UnsupportedStmt(
749+
"`TableFunction` cannot bind in non-From step".to_string(),
750+
));
751+
}
752752
return Ok(ScalarExpression::TableFunction(TableFunction {
753753
args,
754754
inner: ArcTableFunctionImpl(function.clone()),

tests/slt/having.slt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,9 @@ select x from test group by x having max(y) = 22
3232
# 23
3333

3434
statement error
35-
select count(x) from test group by count(x)
35+
select count(x) from test group by count(x)
36+
37+
query II
38+
select y as b, count(*) as total from test where x > 0 group by b having count(*) > 1 order by b
39+
----
40+
2 2

0 commit comments

Comments
 (0)