mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-24 08:32:02 +00:00
Merge pull request #40884 from TKaxe/fix_removeUnneededColumn
fix bug when remove unneeded columns in subquery
This commit is contained in:
commit
7dea71c83f
@ -521,10 +521,15 @@ void removeUnneededColumnsFromSelectClause(ASTSelectQuery * select_query, const
|
||||
++new_elements_size;
|
||||
}
|
||||
/// removing aggregation can change number of rows, so `count()` result in outer sub-query would be wrong
|
||||
if (func && AggregateUtils::isAggregateFunction(*func) && !select_query->groupBy())
|
||||
if (func && !select_query->groupBy())
|
||||
{
|
||||
new_elements[result_index] = elem;
|
||||
++new_elements_size;
|
||||
GetAggregatesVisitor::Data data = {};
|
||||
GetAggregatesVisitor(data).visit(elem);
|
||||
if (!data.aggregates.empty())
|
||||
{
|
||||
new_elements[result_index] = elem;
|
||||
++new_elements_size;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1 +1,2 @@
|
||||
1
|
||||
1
|
||||
|
@ -1 +1,2 @@
|
||||
select count(1) from (SELECT 1 AS a, count(1) FROM numbers(5))
|
||||
select count(1) from (SELECT 1 AS a, count(1) FROM numbers(5));
|
||||
select count(1) from (SELECT 1 AS a, count(1) + 1 FROM numbers(5));
|
Loading…
Reference in New Issue
Block a user