forked from ClickHouse/ClickHouse
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDataTypeTuple.h
More file actions
83 lines (63 loc) · 3.18 KB
/
Copy pathDataTypeTuple.h
File metadata and controls
83 lines (63 loc) · 3.18 KB
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#pragma once
#include <DataTypes/IDataType.h>
#include <optional>
namespace DB
{
/** Tuple data type.
* Used as an intermediate result when evaluating expressions.
* Also can be used as a column - the result of the query execution.
*
* Tuple elements can have names.
* If an element is unnamed, it will have automatically assigned name like '1', '2', '3' corresponding to its position.
* Manually assigned names must not begin with digit. Names must be unique.
*
* All tuples with same size and types of elements are equivalent for expressions, regardless to names of elements.
*/
class DataTypeTuple final : public IDataType
{
private:
DataTypes elems;
Strings names;
bool has_explicit_names;
public:
static constexpr bool is_parametric = true;
explicit DataTypeTuple(const DataTypes & elems);
DataTypeTuple(const DataTypes & elems, const Strings & names);
TypeIndex getTypeId() const override { return TypeIndex::Tuple; }
std::string doGetName() const override;
std::string doGetPrettyName(size_t indent) const override;
const char * getFamilyName() const override { return "Tuple"; }
bool canBeInsideNullable() const override { return true; }
bool supportsSparseSerialization() const override { return true; }
bool canBeInsideSparseColumns() const override { return false; }
MutableColumnPtr createColumn() const override;
MutableColumnPtr createColumn(const ISerialization & serialization) const override;
Field getDefault() const override;
void insertDefaultInto(IColumn & column) const override;
bool equals(const IDataType & rhs) const override;
bool isParametric() const override { return true; }
bool haveSubtypes() const override { return !elems.empty(); }
bool isComparable() const override;
bool textCanContainOnlyValidUTF8() const override;
bool hasDynamicStructure() const override;
bool haveMaximumSizeOfValue() const override;
size_t getMaximumSizeOfValueInMemory() const override;
size_t getSizeOfValueInMemory() const override;
SerializationPtr doGetSerialization(const SerializationInfoSettings & settings) const override;
SerializationPtr getSerialization(const SerializationInfo & info) const override;
MutableSerializationInfoPtr createSerializationInfo(const SerializationInfoSettings & settings) const override;
SerializationInfoPtr getSerializationInfo(const IColumn & column) const override;
DataTypePtr getNormalizedType() const override;
const DataTypePtr & getElement(size_t i) const { return elems[i]; }
const DataTypes & getElements() const { return elems; }
const Strings & getElementNames() const { return names; }
size_t getPositionByName(std::string_view name, bool case_insensitive = false) const;
std::optional<size_t> tryGetPositionByName(std::string_view name, bool case_insensitive = false) const;
String getNameByPosition(size_t i) const;
bool hasExplicitNames() const { return has_explicit_names; }
void updateHashImpl(SipHash & hash) const override;
void forEachChild(const ChildCallback & callback) const override;
private:
SerializationInfoMutablePtr getSerializationInfoImpl(const IColumn & column) const;
};
}