Analyzer subquery in JOIN TREE with aggregation

This commit is contained in:
Maksim Kita 2022-11-01 15:14:07 +01:00
parent cca2620c44
commit 583c65d377
3 changed files with 19 additions and 3 deletions

View File

@ -5527,9 +5527,15 @@ void QueryAnalyzer::resolveQuery(const QueryTreeNodePtr & query_node, Identifier
* 3. Check that there are no columns that are not specified in GROUP BY keys.
* 4. Validate GROUP BY modifiers.
*/
assertNoAggregateFunctionNodes(query_node_typed.getJoinTree(), "in JOIN TREE");
assertNoGroupingFunction(query_node_typed.getJoinTree(), "in JOIN TREE");
assertNoWindowFunctionNodes(query_node_typed.getJoinTree(), "in JOIN TREE");
auto join_tree_node_type = query_node_typed.getJoinTree()->getNodeType();
bool join_tree_is_subquery = join_tree_node_type == QueryTreeNodeType::QUERY || join_tree_node_type == QueryTreeNodeType::UNION;
if (!join_tree_is_subquery)
{
assertNoAggregateFunctionNodes(query_node_typed.getJoinTree(), "in JOIN TREE");
assertNoGroupingFunction(query_node_typed.getJoinTree(), "in JOIN TREE");
assertNoWindowFunctionNodes(query_node_typed.getJoinTree(), "in JOIN TREE");
}
if (query_node_typed.hasWhere())
{

View File

@ -0,0 +1,3 @@
45
--
45

View File

@ -0,0 +1,7 @@
SET allow_experimental_analyzer = 1;
WITH subquery AS (SELECT sum(number) FROM numbers(10)) SELECT * FROM subquery;
SELECT '--';
WITH subquery AS (SELECT sum(number) FROM numbers(10)) SELECT (SELECT * FROM subquery);