ClickHouse

Форк
0
37 строк · 1.3 Кб
1
#include <memory>
2
#include <Processors/QueryPlan/Optimizations/Optimizations.h>
3
#include <Processors/QueryPlan/CreatingSetsStep.h>
4
#include <Common/typeid_cast.h>
5

6
namespace DB::QueryPlanOptimizations
7
{
8

9
bool addPlansForSets(QueryPlan & root_plan, QueryPlan::Node & node, QueryPlan::Nodes & nodes)
10
{
11
    auto * delayed = typeid_cast<DelayedCreatingSetsStep *>(node.step.get());
12
    if (!delayed)
13
        return false;
14

15
    auto plans = DelayedCreatingSetsStep::makePlansForSets(std::move(*delayed));
16
    node.children.reserve(1 + plans.size());
17

18
    DataStreams input_streams;
19
    input_streams.reserve(1 + plans.size());
20
    input_streams.push_back(node.children.front()->step->getOutputStream());
21

22
    for (const auto & plan : plans)
23
    {
24
        input_streams.push_back(plan->getCurrentDataStream());
25
        node.children.push_back(plan->getRootNode());
26
        auto [add_nodes, add_resources] = QueryPlan::detachNodesAndResources(std::move(*plan));
27
        nodes.splice(nodes.end(), std::move(add_nodes));
28
        root_plan.addResources(std::move(add_resources));
29
    }
30

31
    auto creating_sets = std::make_unique<CreatingSetsStep>(std::move(input_streams));
32
    creating_sets->setStepDescription("Create sets before main query execution");
33
    node.step = std::move(creating_sets);
34
    return true;
35
}
36

37
}
38

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.