From 4fbbca075b61d9dfc704476d128904b832c8324c Mon Sep 17 00:00:00 2001 From: Nikita Taranov Date: Wed, 1 Feb 2023 23:01:02 +0000 Subject: [PATCH] review fixes --- .../QueryPlan/Optimizations/useDataParallelAggregation.cpp | 2 +- src/Processors/QueryPlan/ReadFromMergeTree.cpp | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Processors/QueryPlan/Optimizations/useDataParallelAggregation.cpp b/src/Processors/QueryPlan/Optimizations/useDataParallelAggregation.cpp index b0cb3eaac0c..681b8f78c3a 100644 --- a/src/Processors/QueryPlan/Optimizations/useDataParallelAggregation.cpp +++ b/src/Processors/QueryPlan/Optimizations/useDataParallelAggregation.cpp @@ -191,7 +191,7 @@ size_t tryAggregatePartitionsIndependently(QueryPlan::Node * node, QueryPlan::No const auto * expression_node = node->children.front(); const auto * expression_step = typeid_cast(expression_node->step.get()); - if (expression_node->children.size() != 1 || !expression_step) + if (!expression_step) return 0; auto * maybe_reading_step = expression_node->children.front()->step.get(); diff --git a/src/Processors/QueryPlan/ReadFromMergeTree.cpp b/src/Processors/QueryPlan/ReadFromMergeTree.cpp index e0a12166d40..44e81af259b 100644 --- a/src/Processors/QueryPlan/ReadFromMergeTree.cpp +++ b/src/Processors/QueryPlan/ReadFromMergeTree.cpp @@ -49,7 +49,8 @@ template size_t countPartitions(const Container & parts, Getter get_partition_id) { if (parts.empty()) - return 1; + return 0; + String cur_partition_id = get_partition_id(parts[0]); size_t unique_partitions = 1; for (size_t i = 1; i < parts.size(); ++i) @@ -1370,7 +1371,7 @@ Pipe ReadFromMergeTree::groupStreamsByPartition(AnalysisResult & result, Actions if (parts_with_ranges.empty()) return {}; - const size_t partitions_cnt = countPartitions(parts_with_ranges); + const size_t partitions_cnt = std::max(countPartitions(parts_with_ranges), 1); const size_t partitions_per_stream = std::max(1, partitions_cnt / requested_num_streams); const size_t num_streams = std::max(1, requested_num_streams / partitions_cnt);