Skip to content

Commit

Permalink
Fix Build Due to ClickHouse/ClickHouse#73693
Browse files Browse the repository at this point in the history
  • Loading branch information
baibaichen committed Dec 31, 2024
1 parent 2bef7f7 commit 3330ad8
Show file tree
Hide file tree
Showing 11 changed files with 29 additions and 23 deletions.
17 changes: 9 additions & 8 deletions cpp-ch/local-engine/Operator/BranchStep.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ class ResizeStep : public DB::ITransformingStep

private:
size_t num_streams;
void updateOutputHeader() override {};
void updateOutputHeader() override { };
};

DB::QueryPlanPtr BranchStepHelper::createSubPlan(const DB::Block & header, size_t num_streams)
Expand All @@ -156,7 +156,7 @@ DB::QueryPlanPtr BranchStepHelper::createSubPlan(const DB::Block & header, size_
}

StaticBranchStep::StaticBranchStep(
DB::ContextPtr context_, const DB::Block & header_, size_t branches_, size_t sample_rows_, BranchSelector selector_)
const DB::ContextPtr & context_, const DB::Block & header_, size_t branches_, size_t sample_rows_, BranchSelector selector_)
: DB::ITransformingStep(header_, header_, getTraits())
, context(context_)
, header(header_)
Expand All @@ -168,7 +168,7 @@ StaticBranchStep::StaticBranchStep(

void StaticBranchStep::transformPipeline(DB::QueryPipelineBuilder & pipeline, const DB::BuildQueryPipelineSettings & settings)
{
auto build_transform = [&](DB::OutputPortRawPtrs child_outputs) -> DB::Processors
auto build_transform = [&](const DB::OutputPortRawPtrs & child_outputs) -> DB::Processors
{
DB::Processors new_processors;
for (auto & output : child_outputs)
Expand All @@ -195,8 +195,9 @@ void StaticBranchStep::updateOutputHeader()
{
}

UniteBranchesStep::UniteBranchesStep(const DB::Block & header_, std::vector<DB::QueryPlanPtr> && branch_plans_, size_t num_streams_)
: DB::ITransformingStep(header_, branch_plans_[0]->getCurrentHeader(), getTraits()), header(header_)
UniteBranchesStep::UniteBranchesStep(
const DB::ContextPtr & context_, const DB::Block & header_, std::vector<DB::QueryPlanPtr> && branch_plans_, size_t num_streams_)
: DB::ITransformingStep(header_, branch_plans_[0]->getCurrentHeader(), getTraits()), context(context_), header(header_)
{
branch_plans.swap(branch_plans_);
size_t branches = branch_plans.size();
Expand All @@ -217,11 +218,11 @@ void UniteBranchesStep::transformPipeline(DB::QueryPipelineBuilder & pipeline, c
child_outputs.size(),
branch_plans.size());
}
for (auto output : child_outputs)
for (auto * output : child_outputs)
{
auto & branch_plan = branch_plans[branch_index];
DB::QueryPlanOptimizationSettings optimization_settings;
DB::BuildQueryPipelineSettings build_settings;
DB::QueryPlanOptimizationSettings optimization_settings{context};
DB::BuildQueryPipelineSettings build_settings{context};
DB::QueryPlanResourceHolder resource_holder;

auto pipeline_builder = branch_plan->buildQueryPipeline(optimization_settings, build_settings);
Expand Down
6 changes: 4 additions & 2 deletions cpp-ch/local-engine/Operator/BranchStep.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class StaticBranchStep : public DB::ITransformingStep
public:
using BranchSelector = std::function<size_t(const std::list<DB::Chunk> &)>;
explicit StaticBranchStep(
DB::ContextPtr context_, const DB::Block & header, size_t branches, size_t sample_rows, BranchSelector selector);
const DB::ContextPtr & context_, const DB::Block & header, size_t branches, size_t sample_rows, BranchSelector selector);
~StaticBranchStep() override = default;

String getName() const override { return "StaticBranchStep"; }
Expand All @@ -67,7 +67,8 @@ class StaticBranchStep : public DB::ITransformingStep
class UniteBranchesStep : public DB::ITransformingStep
{
public:
explicit UniteBranchesStep(const DB::Block & header_, std::vector<DB::QueryPlanPtr> && branch_plans_, size_t num_streams_);
explicit UniteBranchesStep(
const DB::ContextPtr & context_, const DB::Block & header_, std::vector<DB::QueryPlanPtr> && branch_plans_, size_t num_streams_);
~UniteBranchesStep() override = default;

String getName() const override { return "UniteBranchesStep"; }
Expand All @@ -76,6 +77,7 @@ class UniteBranchesStep : public DB::ITransformingStep
void describePipeline(DB::IQueryPlanStep::FormatSettings & settings) const override;

private:
DB::ContextPtr context;
DB::Block header;
std::vector<DB::QueryPlanPtr> branch_plans;
size_t num_streams;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ DB::QueryPlanPtr AggregateGroupLimitRelParser::parse(
std::vector<DB::QueryPlanPtr> branch_plans;
branch_plans.emplace_back(std::move(aggregation_plan));
branch_plans.emplace_back(std::move(window_plan));
auto unite_branches_step = std::make_unique<UniteBranchesStep>(branch_in_header, std::move(branch_plans), 1);
auto unite_branches_step = std::make_unique<UniteBranchesStep>(getContext(), branch_in_header, std::move(branch_plans), 1);
unite_branches_step->setStepDescription("Unite TopK branches");
steps.push_back(unite_branches_step.get());

Expand Down
4 changes: 2 additions & 2 deletions cpp-ch/local-engine/Parser/RelParsers/JoinRelParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -599,8 +599,8 @@ bool JoinRelParser::applyJoinFilter(
return false;
auto mixed_join_expressions_actions = expressionsToActionsDAG({expr}, mixed_header);
mixed_join_expressions_actions.removeUnusedActions();
table_join.getMixedJoinExpression() = std::make_shared<DB::ExpressionActions>(
std::move(mixed_join_expressions_actions), ExpressionActionsSettings::fromContext(context));
table_join.getMixedJoinExpression()
= std::make_shared<DB::ExpressionActions>(std::move(mixed_join_expressions_actions), ExpressionActionsSettings(context));
}
else
{
Expand Down
4 changes: 2 additions & 2 deletions cpp-ch/local-engine/Parser/SerializedPlanParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -303,8 +303,8 @@ DB::QueryPipelineBuilderPtr SerializedPlanParser::buildQueryPipeline(DB::QueryPl
IAST::QueryKind::Select,
settings,
0);
const QueryPlanOptimizationSettings optimization_settings{.optimize_plan = settings[Setting::query_plan_enable_optimizations]};
BuildQueryPipelineSettings build_settings = BuildQueryPipelineSettings::fromContext(context);
const QueryPlanOptimizationSettings optimization_settings{context};
BuildQueryPipelineSettings build_settings = BuildQueryPipelineSettings{context};
build_settings.process_list_element = query_status;
build_settings.progress_callback = nullptr;
return query_plan.buildQueryPipeline(optimization_settings, build_settings);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class FunctionParserArrayExcept : public FunctionParser
NamesAndTypesList lambda_arguments_names_and_types;
lambda_arguments_names_and_types.emplace_back(x_in_lambda->result_name, x_in_lambda->result_type);
DB::Names required_column_names = lambda_actions_dag.getRequiredColumnsNames();
auto expression_actions_settings = DB::ExpressionActionsSettings::fromContext(getContext(), DB::CompileExpressions::yes);
auto expression_actions_settings = DB::ExpressionActionsSettings{getContext(), DB::CompileExpressions::yes};
auto function_capture = std::make_shared<FunctionCaptureOverloadResolver>(
std::move(lambda_actions_dag),
expression_actions_settings,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class FunctionParserArrayRemove : public FunctionParser
NamesAndTypesList lambda_arguments_names_and_types;
lambda_arguments_names_and_types.emplace_back(x_in_lambda->result_name, x_in_lambda->result_type);
DB::Names required_column_names = lambda_actions_dag.getRequiredColumnsNames();
auto expression_actions_settings = DB::ExpressionActionsSettings::fromContext(getContext(), DB::CompileExpressions::yes);
auto expression_actions_settings = DB::ExpressionActionsSettings{getContext(), DB::CompileExpressions::yes};
auto function_capture = std::make_shared<FunctionCaptureOverloadResolver>(
std::move(lambda_actions_dag),
expression_actions_settings,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class FunctionParserArrayRepeat : public FunctionParser
NamesAndTypesList lambda_arguments_names_and_types;
lambda_arguments_names_and_types.emplace_back(x_in_lambda->result_name, x_in_lambda->result_type);
DB::Names required_column_names = lambda_actions_dag.getRequiredColumnsNames();
auto expression_actions_settings = DB::ExpressionActionsSettings::fromContext(getContext(), DB::CompileExpressions::yes);
auto expression_actions_settings = DB::ExpressionActionsSettings{getContext(), DB::CompileExpressions::yes};
auto function_capture = std::make_shared<FunctionCaptureOverloadResolver>(
std::move(lambda_actions_dag),
expression_actions_settings,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ class FunctionParserLambda : public FunctionParser
captured_column_names.push_back(required_column_name);
}
}
auto expression_actions_settings = DB::ExpressionActionsSettings::fromContext(getContext(), DB::CompileExpressions::yes);
auto expression_actions_settings = DB::ExpressionActionsSettings{getContext(), DB::CompileExpressions::yes};
auto function_capture = std::make_shared<DB::FunctionCaptureOverloadResolver>(
std::move(lambda_actions_dag),
expression_actions_settings,
Expand Down
4 changes: 3 additions & 1 deletion cpp-ch/local-engine/Storages/Cache/CacheManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,9 @@ Task CacheManager::cachePart(
1);
QueryPlan plan;
plan.addStep(std::move(read_step));
auto pipeline_builder = plan.buildQueryPipeline({}, {});
DB::QueryPlanOptimizationSettings optimization_settings{context};
DB::BuildQueryPipelineSettings build_settings{context};
auto pipeline_builder = plan.buildQueryPipeline(optimization_settings, build_settings);
auto pipeline = QueryPipelineBuilder::getPipeline(std::move(*pipeline_builder.get()));
PullingPipelineExecutor executor(pipeline);
while (true)
Expand Down
7 changes: 4 additions & 3 deletions cpp-ch/local-engine/tests/gtest_ch_join.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,8 @@ TEST(TestJoin, simple)
}
auto hash_join = std::make_shared<HashJoin>(join, right_plan.getCurrentHeader());

QueryPlanStepPtr join_step
= std::make_unique<JoinStep>(left_plan.getCurrentHeader(), right_plan.getCurrentHeader(), hash_join, 8192, 8192, 1, NameSet{}, false, false);
QueryPlanStepPtr join_step = std::make_unique<JoinStep>(
left_plan.getCurrentHeader(), right_plan.getCurrentHeader(), hash_join, 8192, 8192, 1, NameSet{}, false, false);

std::cerr << "join step:" << join_step->getOutputHeader().dumpStructure() << std::endl;

Expand All @@ -143,7 +143,8 @@ TEST(TestJoin, simple)
{NameWithAlias("colA", "colA"), NameWithAlias("colB", "colB"), NameWithAlias("colD", "colD"), NameWithAlias("colC", "colC")});
QueryPlanStepPtr project_step = std::make_unique<ExpressionStep>(query_plan.getCurrentHeader(), std::move(project));
query_plan.addStep(std::move(project_step));
auto pipeline = query_plan.buildQueryPipeline(QueryPlanOptimizationSettings(), BuildQueryPipelineSettings());
auto pipeline
= query_plan.buildQueryPipeline(QueryPlanOptimizationSettings{global_context}, BuildQueryPipelineSettings{global_context});
auto executable_pipe = QueryPipelineBuilder::getPipeline(std::move(*pipeline));
PullingPipelineExecutor executor(executable_pipe);
auto res = pipeline->getHeader().cloneEmpty();
Expand Down

0 comments on commit 3330ad8

Please sign in to comment.