blob: 7bdccb59b8aded7012534b4467f361ea6836fd89 (
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
37
38
39
40
41
42
43
44
45
46
|
#pragma once
#include "clickhouse_config.h"
#if USE_ARROW || USE_PARQUET
#include <Core/Block.h>
#include <Processors/Chunk.h>
#error #include <arrow/table.h>
namespace DB
{
class CHColumnToArrowColumn
{
public:
CHColumnToArrowColumn(const Block & header, const std::string & format_name_, bool low_cardinality_as_dictionary_, bool output_string_as_string_, bool output_fixed_string_as_fixed_byte_array_);
void chChunkToArrowTable(std::shared_ptr<arrow::Table> & res, const std::vector<Chunk> & chunk, size_t columns_num);
private:
ColumnsWithTypeAndName header_columns;
std::vector<std::shared_ptr<arrow::Field>> arrow_fields;
const std::string format_name;
bool low_cardinality_as_dictionary;
/// Map {column name : arrow dictionary}.
/// To avoid converting dictionary from LowCardinality to Arrow
/// Dictionary every chunk we save it and reuse.
std::unordered_map<std::string, MutableColumnPtr> dictionary_values;
/// We should initialize arrow fields on first call of chChunkToArrowTable, not in constructor
/// because LowCardinality column from header always has indexes type UInt8, so, we should get
/// proper indexes type from first chunk of data.
bool is_arrow_fields_initialized = false;
/// Output columns with String data type as Arrow::String type.
/// By default Arrow::Binary is used.
bool output_string_as_string = false;
/// Output columns with String data type as Arrow::FixedByteArray type.
bool output_fixed_string_as_fixed_byte_array = true;
};
}
#endif
|