blob: c20e598580f11b201f1edaf292e6df6205b60c01 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
#pragma once
#include <Core/Block.h>
#include <Formats/FormatSettings.h>
namespace DB
{
/// Used for input text formats with headers/structure to map columns from input
/// and columns in header by names.
/// It's also used to pass info from header between different InputFormats in ParallelParsing
struct ColumnMapping
{
/// Special flag for ParallelParsing. Non-atomic because there is strict
/// `happens-before` between read and write access. See InputFormatParallelParsing
bool is_set{false};
/// Maps indexes of columns in the input file to indexes of table columns
using OptionalIndexes = std::vector<std::optional<size_t>>;
OptionalIndexes column_indexes_for_input_fields;
/// The list of column indexes that are not presented in input data.
std::vector<size_t> not_presented_columns;
/// The list of column names in input data. Needed for better exception messages.
std::vector<String> names_of_columns;
void setupByHeader(const Block & header);
void addColumns(
const Names & column_names, const Block::NameMap & column_indexes_by_names, const FormatSettings & settings);
void insertDefaultsForNotSeenColumns(MutableColumns & columns, std::vector<UInt8> & read_columns);
};
}
|