| 1 | #pragma once |
|---|---|
| 2 | |
| 3 | #include <DataStreams/IBlockInputStream.h> |
| 4 | #include <Interpreters/FillingRow.h> |
| 5 | |
| 6 | namespace DB |
| 7 | { |
| 8 | |
| 9 | /** Implements modifier WITH FILL of ORDER BY clause. |
| 10 | * It fills gaps in data stream by rows with missing values in columns with set WITH FILL and deafults in other columns. |
| 11 | * Optionally FROM, TO and STEP values can be specified. |
| 12 | */ |
| 13 | class FillingBlockInputStream : public IBlockInputStream |
| 14 | { |
| 15 | public: |
| 16 | FillingBlockInputStream(const BlockInputStreamPtr & input, const SortDescription & fill_description_); |
| 17 | |
| 18 | String getName() const override { return "Filling"; } |
| 19 | |
| 20 | Block getHeader() const override { return header; } |
| 21 | |
| 22 | protected: |
| 23 | Block readImpl() override; |
| 24 | |
| 25 | private: |
| 26 | Block createResultBlock(MutableColumns & fill_columns, MutableColumns & other_columns) const; |
| 27 | |
| 28 | const SortDescription sort_description; /// Contains only rows with WITH FILL. |
| 29 | FillingRow filling_row; /// Current row, which is used to fill gaps. |
| 30 | FillingRow next_row; /// Row to which we need to generate filling rows. |
| 31 | Block header; |
| 32 | |
| 33 | using Positions = std::vector<size_t>; |
| 34 | Positions fill_column_positions; |
| 35 | Positions other_column_positions; |
| 36 | bool first = true; |
| 37 | }; |
| 38 | |
| 39 | } |
| 40 |