From cd302eacc10660f7a7b5f62956f9104348625958 Mon Sep 17 00:00:00 2001 From: Amos Bird Date: Sat, 31 Jul 2021 15:44:16 +0800 Subject: [PATCH] Fix projection match --- src/Storages/MergeTree/MergeTreeData.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Storages/MergeTree/MergeTreeData.cpp b/src/Storages/MergeTree/MergeTreeData.cpp index a268468ea59..081444c68b5 100644 --- a/src/Storages/MergeTree/MergeTreeData.cpp +++ b/src/Storages/MergeTree/MergeTreeData.cpp @@ -4122,7 +4122,8 @@ bool MergeTreeData::getQueryProcessingStageWithAggregateProjection( candidate.before_aggregation = analysis_result.before_aggregation->clone(); auto required_columns = candidate.before_aggregation->foldActionsByProjection(keys, projection.sample_block_for_keys); - if (required_columns.empty() && !keys.empty()) + // TODO Let's find out the exact required_columns for keys. + if (required_columns.empty() && (!keys.empty() && !candidate.before_aggregation->getRequiredColumns().empty())) continue; if (analysis_result.optimize_aggregation_in_order)