diff --git a/ydb/library/yql/providers/dq/planner/execution_planner.cpp b/ydb/library/yql/providers/dq/planner/execution_planner.cpp index 89ded7a01d8e..c2605765e82b 100644 --- a/ydb/library/yql/providers/dq/planner/execution_planner.cpp +++ b/ydb/library/yql/providers/dq/planner/execution_planner.cpp @@ -571,24 +571,27 @@ namespace NYql::NDqs { return !parts.empty(); } -#define BUILD_CONNECTION(TYPE, BUILDER) \ - if (auto conn = input.Maybe()) { \ - BUILDER(TasksGraph, stage, inputIndex, logFunc); \ - continue; \ - } - - void TDqsExecutionPlanner::BuildConnections( const NNodes::TDqPhyStage& stage) { + const static std::unordered_map< + std::string_view, + void(*)(TDqsTasksGraph&, const NNodes::TDqPhyStage&, ui32, const TChannelLogFunc&) + > ConnectionBuilders = { + {TDqCnUnionAll::CallableName(), &BuildUnionAllChannels}, + {TDqCnHashShuffle::CallableName(), &BuildHashShuffleChannels}, + {TDqCnBroadcast::CallableName(), &BuildBroadcastChannels}, + {TDqCnMap::CallableName(), BuildMapChannels}, + {TDqCnMerge::CallableName(), BuildMergeChannels}, + }; + + void TDqsExecutionPlanner::BuildConnections(const NNodes::TDqPhyStage& stage) { NDq::TChannelLogFunc logFunc = [](ui64, ui64, ui64, TStringBuf, bool) {}; - for (ui32 inputIndex = 0; inputIndex < stage.Inputs().Size(); ++inputIndex) { - const auto& input = stage.Inputs().Item(inputIndex); + const auto &input = stage.Inputs().Item(inputIndex); if (input.Maybe()) { - BUILD_CONNECTION(TDqCnUnionAll, BuildUnionAllChannels); - BUILD_CONNECTION(TDqCnHashShuffle, BuildHashShuffleChannels); - BUILD_CONNECTION(TDqCnBroadcast, BuildBroadcastChannels); - BUILD_CONNECTION(TDqCnMap, BuildMapChannels); - BUILD_CONNECTION(TDqCnMerge, BuildMergeChannels); - YQL_ENSURE(false, "Unknown stage connection type: " << input.Cast().CallableName()); + if (const auto it = ConnectionBuilders.find(input.Cast().CallableName()); it != ConnectionBuilders.cend()) { + it->second(TasksGraph, stage, inputIndex, logFunc); + } else { + YQL_ENSURE(false, "Unknown stage connection type: " << input.Cast().CallableName()); + } } else { YQL_ENSURE(input.Maybe(), "Unknown stage input: " << input.Cast().CallableName()); }