mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-23 16:12:01 +00:00
Prohibit optimize_aggregation_in_order with GROUPING SETS
AggregatingStep ignores it anyway, and it leads to the following error in getSortDescriptionFromGroupBy(), like in [1]: 2022.05.24 04:29:29.279431 [ 3395 ] {26543564-8bc8-4a3a-b984-70a2adf0245d} <Fatal> : Logical error: 'Trying to get name of not a column: ExpressionList'. [1]: https://s3.amazonaws.com/clickhouse-test-reports/36914/67d3ac72d26ab74d69f03c03422349d4faae9e19/stateless_tests__ubsan__actions_.html v2: revert change to getSortDescriptionFromGroupBy() after GroupingSetsRewriterVisitor had been introduced Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com>
This commit is contained in:
parent
1f29b0a901
commit
8a224239c1
@ -2060,12 +2060,15 @@ void InterpreterSelectQuery::executeFetchColumns(QueryProcessingStage::Enum proc
|
||||
if (prewhere_info)
|
||||
query_info.prewhere_info = prewhere_info;
|
||||
|
||||
bool optimize_read_in_order = analysis_result.optimize_read_in_order;
|
||||
bool optimize_aggregation_in_order = analysis_result.optimize_aggregation_in_order && !query_analyzer->useGroupingSetKey();
|
||||
|
||||
/// Create optimizer with prepared actions.
|
||||
/// Maybe we will need to calc input_order_info later, e.g. while reading from StorageMerge.
|
||||
if ((analysis_result.optimize_read_in_order || analysis_result.optimize_aggregation_in_order)
|
||||
if ((optimize_read_in_order || optimize_aggregation_in_order)
|
||||
&& (!query_info.projection || query_info.projection->complete))
|
||||
{
|
||||
if (analysis_result.optimize_read_in_order)
|
||||
if (optimize_read_in_order)
|
||||
{
|
||||
if (query_info.projection)
|
||||
{
|
||||
@ -2291,7 +2294,7 @@ void InterpreterSelectQuery::executeAggregation(QueryPlan & query_plan, const Ac
|
||||
|
||||
SortDescription group_by_sort_description;
|
||||
|
||||
if (group_by_info && settings.optimize_aggregation_in_order)
|
||||
if (group_by_info && settings.optimize_aggregation_in_order && !query_analyzer->useGroupingSetKey())
|
||||
group_by_sort_description = getSortDescriptionFromGroupBy(getSelectQuery());
|
||||
else
|
||||
group_by_info = nullptr;
|
||||
|
@ -285,3 +285,76 @@ ORDER BY fact_3_id ASC NULLS FIRST;
|
||||
8
|
||||
9
|
||||
10
|
||||
SELECT fact_3_id, fact_4_id, count()
|
||||
FROM grouping_sets
|
||||
GROUP BY
|
||||
GROUPING SETS (
|
||||
( fact_3_id, fact_4_id))
|
||||
ORDER BY fact_3_id, fact_4_id
|
||||
SETTINGS optimize_aggregation_in_order=1;
|
||||
1 1 100
|
||||
2 2 100
|
||||
3 3 100
|
||||
4 4 100
|
||||
5 5 100
|
||||
6 6 100
|
||||
7 7 100
|
||||
8 8 100
|
||||
9 9 100
|
||||
10 10 100
|
||||
SELECT fact_3_id, fact_4_id, count()
|
||||
FROM grouping_sets
|
||||
GROUP BY
|
||||
GROUPING SETS (
|
||||
fact_3_id,
|
||||
fact_4_id)
|
||||
ORDER BY fact_3_id, fact_4_id
|
||||
SETTINGS optimize_aggregation_in_order=1;
|
||||
0 1 100
|
||||
0 2 100
|
||||
0 3 100
|
||||
0 4 100
|
||||
0 5 100
|
||||
0 6 100
|
||||
0 7 100
|
||||
0 8 100
|
||||
0 9 100
|
||||
0 10 100
|
||||
1 0 100
|
||||
2 0 100
|
||||
3 0 100
|
||||
4 0 100
|
||||
5 0 100
|
||||
6 0 100
|
||||
7 0 100
|
||||
8 0 100
|
||||
9 0 100
|
||||
10 0 100
|
||||
SELECT fact_3_id, fact_4_id, count()
|
||||
FROM grouping_sets
|
||||
GROUP BY
|
||||
GROUPING SETS (
|
||||
( fact_3_id ),
|
||||
( fact_3_id, fact_4_id))
|
||||
ORDER BY fact_3_id, fact_4_id
|
||||
SETTINGS optimize_aggregation_in_order=1;
|
||||
1 0 100
|
||||
1 1 100
|
||||
2 0 100
|
||||
2 2 100
|
||||
3 0 100
|
||||
3 3 100
|
||||
4 0 100
|
||||
4 4 100
|
||||
5 0 100
|
||||
5 5 100
|
||||
6 0 100
|
||||
6 6 100
|
||||
7 0 100
|
||||
7 7 100
|
||||
8 0 100
|
||||
8 8 100
|
||||
9 0 100
|
||||
9 9 100
|
||||
10 0 100
|
||||
10 10 100
|
||||
|
@ -97,5 +97,31 @@ GROUP BY
|
||||
( fact_3_id, fact_4_id))
|
||||
ORDER BY fact_3_id ASC NULLS FIRST;
|
||||
|
||||
SELECT fact_3_id, fact_4_id, count()
|
||||
FROM grouping_sets
|
||||
GROUP BY
|
||||
GROUPING SETS (
|
||||
( fact_3_id, fact_4_id))
|
||||
ORDER BY fact_3_id, fact_4_id
|
||||
SETTINGS optimize_aggregation_in_order=1;
|
||||
|
||||
SELECT fact_3_id, fact_4_id, count()
|
||||
FROM grouping_sets
|
||||
GROUP BY
|
||||
GROUPING SETS (
|
||||
fact_3_id,
|
||||
fact_4_id)
|
||||
ORDER BY fact_3_id, fact_4_id
|
||||
SETTINGS optimize_aggregation_in_order=1;
|
||||
|
||||
SELECT fact_3_id, fact_4_id, count()
|
||||
FROM grouping_sets
|
||||
GROUP BY
|
||||
GROUPING SETS (
|
||||
( fact_3_id ),
|
||||
( fact_3_id, fact_4_id))
|
||||
ORDER BY fact_3_id, fact_4_id
|
||||
SETTINGS optimize_aggregation_in_order=1;
|
||||
|
||||
-- { echoOff }
|
||||
DROP TABLE IF EXISTS grouping_sets;
|
||||
|
Loading…
Reference in New Issue
Block a user