Calculate common header for pipes. This function is needed only to remove ColumnConst from common header in case if some columns are const, and some not. E.g. if the first header is `x, const y, const z` and the second is `const x, y, const z`, the common header will be `x, y, const z`.
| 251 | /// This function is needed only to remove ColumnConst from common header in case if some columns are const, and some not. |
| 252 | /// E.g. if the first header is `x, const y, const z` and the second is `const x, y, const z`, the common header will be `x, y, const z`. |
| 253 | static Block getCommonHeader(const Pipes & pipes) |
| 254 | { |
| 255 | Block res; |
| 256 | |
| 257 | for (const auto & pipe : pipes) |
| 258 | { |
| 259 | if (const auto & header = pipe.getHeader(); !header.empty()) |
| 260 | { |
| 261 | res = header; |
| 262 | break; |
| 263 | } |
| 264 | } |
| 265 | |
| 266 | for (const auto & pipe : pipes) |
| 267 | { |
| 268 | const auto & header = pipe.getHeader(); |
| 269 | for (size_t i = 0; i < res.columns(); ++i) |
| 270 | { |
| 271 | /// We do not check that headers are compatible here. Will do it later. |
| 272 | |
| 273 | if (i >= header.columns()) |
| 274 | break; |
| 275 | |
| 276 | auto & common = res.getByPosition(i).column; |
| 277 | const auto & cur = header.getByPosition(i).column; |
| 278 | |
| 279 | /// Only remove const from common header if it is not const for current pipe. |
| 280 | if (cur && common && !isColumnConst(*cur)) |
| 281 | { |
| 282 | if (const auto * column_const = typeid_cast<const ColumnConst *>(common.get())) |
| 283 | common = column_const->getDataColumnPtr(); |
| 284 | } |
| 285 | } |
| 286 | } |
| 287 | |
| 288 | return res; |
| 289 | } |
| 290 | |
| 291 | Pipe Pipe::unitePipes(Pipes pipes) |
| 292 | { |
no test coverage detected