1 | #pragma once |
---|---|
2 | |
3 | #include <DataStreams/IBlockInputStream.h> |
4 | #include <Storages/ColumnDefault.h> |
5 | #include <Interpreters/Context.h> |
6 | |
7 | |
8 | namespace DB |
9 | { |
10 | |
11 | /// Adds defaults to columns using BlockDelayedDefaults bitmask attached to Block by child InputStream. |
12 | class AddingDefaultsBlockInputStream : public IBlockInputStream |
13 | { |
14 | public: |
15 | AddingDefaultsBlockInputStream( |
16 | const BlockInputStreamPtr & input, |
17 | const ColumnDefaults & column_defaults_, |
18 | const Context & context_); |
19 | |
20 | String getName() const override { return "AddingDefaults"; } |
21 | Block getHeader() const override { return header; } |
22 | |
23 | protected: |
24 | Block readImpl() override; |
25 | |
26 | private: |
27 | Block header; |
28 | const ColumnDefaults column_defaults; |
29 | const Context & context; |
30 | |
31 | void checkCalculated(const ColumnWithTypeAndName & col_read, const ColumnWithTypeAndName & col_defaults, size_t needed) const; |
32 | MutableColumnPtr mixColumns(const ColumnWithTypeAndName & col_read, const ColumnWithTypeAndName & col_defaults, |
33 | const BlockMissingValues::RowsBitMask & defaults_mask) const; |
34 | void mixNumberColumns(TypeIndex type_idx, MutableColumnPtr & col_mixed, const ColumnPtr & col_defaults, |
35 | const BlockMissingValues::RowsBitMask & defaults_mask) const; |
36 | }; |
37 | |
38 | } |
39 |