Skip to content

Commit c259404

Browse files
committed
fix(query): group checker subquery
1 parent 5581d25 commit c259404

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

src/query/sql/src/planner/semantic/grouping_check.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ use crate::binder::Visibility;
2020
use crate::plans::walk_expr_mut;
2121
use crate::plans::BoundColumnRef;
2222
use crate::plans::ScalarExpr;
23-
use crate::plans::SubqueryExpr;
2423
use crate::plans::VisitorMut;
2524
use crate::BindContext;
2625

@@ -176,6 +175,11 @@ impl VisitorMut<'_> for GroupingChecker<'_> {
176175
return Ok(());
177176
}
178177
}
178+
ScalarExpr::SubqueryExpr(q) => {
179+
if let Some(c) = q.child_expr.as_mut() {
180+
self.visit(c.as_mut())?;
181+
}
182+
}
179183
_ => {}
180184
}
181185

@@ -200,9 +204,4 @@ impl VisitorMut<'_> for GroupingChecker<'_> {
200204
))
201205
.set_span(column.span))
202206
}
203-
204-
fn visit_subquery_expr(&mut self, _: &mut SubqueryExpr) -> Result<()> {
205-
// TODO(leiysky): check subquery in the future
206-
Ok(())
207-
}
208207
}

tests/sqllogictests/suites/query/aggregate.test

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ select a, sum(sum) as sum from (select a, sum(a) as sum from t group by a, b) as
3636
1 2
3737
2 4
3838

39+
statement error must appear in the GROUP BY clause or be used in an aggregate function
40+
SELECT max(a) FROM t GROUP BY a HAVING b NOT IN(SELECT 3 AS c);
41+
3942
statement ok
4043
drop table t
4144

0 commit comments

Comments
 (0)