Skip to content

Commit c54e4d2

Browse files
committed
Format
1 parent fbfba60 commit c54e4d2

File tree

1 file changed

+13
-25
lines changed

1 file changed

+13
-25
lines changed

src/Processors/QueryPlan/Optimizations/optimizeUseNormalProjection.cpp

Lines changed: 13 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,15 @@
1-
#include <Processors/QueryPlan/Optimizations/Optimizations.h>
2-
#include <Processors/QueryPlan/Optimizations/projectionsCommon.h>
1+
#include <Core/Settings.h>
32
#include <Processors/QueryPlan/ExpressionStep.h>
43
#include <Processors/QueryPlan/FilterStep.h>
4+
#include <Processors/QueryPlan/Optimizations/Optimizations.h>
5+
#include <Processors/QueryPlan/Optimizations/projectionsCommon.h>
56
#include <Processors/QueryPlan/ReadFromMergeTree.h>
6-
#include <Processors/QueryPlan/UnionStep.h>
77
#include <Processors/QueryPlan/ReadFromPreparedSource.h>
8+
#include <Processors/QueryPlan/UnionStep.h>
89
#include <Processors/Sources/NullSource.h>
9-
#include <Common/logger_useful.h>
10-
#include <Core/Settings.h>
10+
#include <Storages/MergeTree/MergeTreeDataSelectExecutor.h>
1111
#include <Storages/ProjectionsDescription.h>
1212
#include <Storages/SelectQueryInfo.h>
13-
#include <Storages/MergeTree/MergeTreeDataSelectExecutor.h>
14-
15-
#include <algorithm>
1613

1714
namespace DB
1815
{
@@ -88,8 +85,7 @@ std::optional<String> optimizeUseNormalProjections(Stack & stack, QueryPlan::Nod
8885
{
8986
iter = std::next(iter);
9087

91-
if (!typeid_cast<FilterStep *>(iter->node->step.get()) &&
92-
!typeid_cast<ExpressionStep *>(iter->node->step.get()))
88+
if (!typeid_cast<FilterStep *>(iter->node->step.get()) && !typeid_cast<ExpressionStep *>(iter->node->step.get()))
9389
break;
9490
}
9591

@@ -122,16 +118,13 @@ std::optional<String> optimizeUseNormalProjections(Stack & stack, QueryPlan::Nod
122118
normal_projections.push_back(preferred_projection);
123119
}
124120

125-
bool with_parent_part_offset = std::any_of(
126-
normal_projections.begin(),
127-
normal_projections.end(),
128-
[](const auto & projection) { return projection->with_parent_part_offset; });
129-
130121
Names required_columns = reading->getAllColumnNames();
131122

132123
/// If `with_parent_part_offset` is true and the required columns include `_part_offset`,
133124
/// we need to remap it to `_parent_part_offset`. This ensures that the projection's
134125
/// ActionsDAG reads from the correct column and generates `_part_offset` in the output.
126+
bool with_parent_part_offset = std::any_of(
127+
normal_projections.begin(), normal_projections.end(), [](const auto & projection) { return projection->with_parent_part_offset; });
135128
bool need_parent_part_offset = false;
136129
if (with_parent_part_offset)
137130
{
@@ -273,7 +266,7 @@ std::optional<String> optimizeUseNormalProjections(Stack & stack, QueryPlan::Nod
273266
query_info_copy.prewhere_info = nullptr;
274267

275268
auto projection_reading = reader.readFromParts(
276-
/*parts=*/ {},
269+
/*parts=*/{},
277270
reading->getMutationsSnapshot()->cloneEmpty(),
278271
required_columns,
279272
proj_snapshot,
@@ -293,8 +286,7 @@ std::optional<String> optimizeUseNormalProjections(Stack & stack, QueryPlan::Nod
293286

294287
if (!query_info.is_internal && context->hasQueryContext())
295288
{
296-
context->getQueryContext()->addQueryAccessInfo(Context::QualifiedProjectionName
297-
{
289+
context->getQueryContext()->addQueryAccessInfo(Context::QualifiedProjectionName{
298290
.storage_id = reading->getMergeTreeData().getStorageID(),
299291
.projection_name = best_candidate->projection->name,
300292
});
@@ -316,15 +308,11 @@ std::optional<String> optimizeUseNormalProjections(Stack & stack, QueryPlan::Nod
316308
if (query.filter_node)
317309
{
318310
expr_or_filter_node.step = std::make_unique<FilterStep>(
319-
projection_reading_node.step->getOutputHeader(),
320-
std::move(*query.dag),
321-
query.filter_node->result_name,
322-
true);
311+
projection_reading_node.step->getOutputHeader(), std::move(*query.dag), query.filter_node->result_name, true);
323312
}
324313
else
325-
expr_or_filter_node.step = std::make_unique<ExpressionStep>(
326-
projection_reading_node.step->getOutputHeader(),
327-
std::move(*query.dag));
314+
expr_or_filter_node.step
315+
= std::make_unique<ExpressionStep>(projection_reading_node.step->getOutputHeader(), std::move(*query.dag));
328316

329317
expr_or_filter_node.children.push_back(&projection_reading_node);
330318
next_node = &expr_or_filter_node;

0 commit comments

Comments
 (0)