| 89 | } |
| 90 | |
| 91 | static void addConvertingActions(Pipe & pipe, const Block & header, const ContextPtr & context, bool use_positions_to_match = false) |
| 92 | { |
| 93 | if (blocksHaveEqualStructure(pipe.getHeader(), header)) |
| 94 | return; |
| 95 | |
| 96 | auto match_mode = use_positions_to_match ? ActionsDAG::MatchColumnsMode::Position : ActionsDAG::MatchColumnsMode::Name; |
| 97 | |
| 98 | auto get_converting_dag = [mode = match_mode, context](const Block & block_, const Block & header_) |
| 99 | { |
| 100 | /// Convert header structure to expected. |
| 101 | /// Also we ignore constants from result and replace it with constants from header. |
| 102 | /// It is needed for functions like `now64()` or `randConstant()` because their values may be different. |
| 103 | return ActionsDAG::makeConvertingActions( |
| 104 | block_.getColumnsWithTypeAndName(), |
| 105 | header_.getColumnsWithTypeAndName(), |
| 106 | mode, |
| 107 | context, |
| 108 | true); |
| 109 | }; |
| 110 | |
| 111 | if (use_positions_to_match) |
| 112 | pipe.addSimpleTransform([](const SharedHeader & stream_header) { return std::make_shared<MaterializingTransform>(stream_header); }); |
| 113 | |
| 114 | auto convert_actions = std::make_shared<ExpressionActions>(get_converting_dag(pipe.getHeader(), header)); |
| 115 | pipe.addSimpleTransform([&](const SharedHeader & cur_header, Pipe::StreamType) -> ProcessorPtr |
| 116 | { |
| 117 | return std::make_shared<ExpressionTransform>(cur_header, convert_actions); |
| 118 | }); |
| 119 | } |
| 120 | |
| 121 | static void enableMemoryBoundMerging(QueryProcessingStage::Enum stage, const ClusterProxy::SelectStreamFactory::Shards * shards, Context & context) |
| 122 | { |
no test coverage detected