Skip to content

fix(query): group checker subquery #17420

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

Merged
merged 1 commit into from
Feb 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
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
11 changes: 5 additions & 6 deletions src/query/sql/src/planner/semantic/grouping_check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ use crate::binder::Visibility;
use crate::plans::walk_expr_mut;
use crate::plans::BoundColumnRef;
use crate::plans::ScalarExpr;
use crate::plans::SubqueryExpr;
use crate::plans::VisitorMut;
use crate::BindContext;

Expand Down Expand Up @@ -176,6 +175,11 @@ impl VisitorMut<'_> for GroupingChecker<'_> {
return Ok(());
}
}
ScalarExpr::SubqueryExpr(q) => {
if let Some(c) = q.child_expr.as_mut() {
self.visit(c.as_mut())?;
}
}
_ => {}
}

Expand All @@ -200,9 +204,4 @@ impl VisitorMut<'_> for GroupingChecker<'_> {
))
.set_span(column.span))
}

fn visit_subquery_expr(&mut self, _: &mut SubqueryExpr) -> Result<()> {
// TODO(leiysky): check subquery in the future
Ok(())
}
}
3 changes: 3 additions & 0 deletions tests/sqllogictests/suites/query/aggregate.test
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ select a, sum(sum) as sum from (select a, sum(a) as sum from t group by a, b) as
1 2
2 4

statement error must appear in the GROUP BY clause or be used in an aggregate function
SELECT max(a) FROM t GROUP BY a HAVING b NOT IN(SELECT 3 AS c);

statement ok
drop table t

Expand Down