1#include <DataStreams/FilterColumnsBlockInputStream.h>
2
3namespace DB
4{
5
6Block FilterColumnsBlockInputStream::getHeader() const
7{
8 Block block = children.back()->getHeader();
9 Block filtered;
10
11 for (const auto & it : columns_to_save)
12 if (throw_if_column_not_found || block.has(it))
13 filtered.insert(std::move(block.getByName(it)));
14
15 return filtered;
16}
17
18Block FilterColumnsBlockInputStream::readImpl()
19{
20 Block block = children.back()->read();
21
22 if (!block)
23 return block;
24
25 Block filtered;
26
27 for (const auto & it : columns_to_save)
28 if (throw_if_column_not_found || block.has(it))
29 filtered.insert(std::move(block.getByName(it)));
30
31 return filtered;
32}
33
34}
35