-
Notifications
You must be signed in to change notification settings - Fork 8.6k
Expand file tree
/
Copy pathDataTypeDynamic.h
More file actions
62 lines (43 loc) · 2.2 KB
/
Copy pathDataTypeDynamic.h
File metadata and controls
62 lines (43 loc) · 2.2 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
#pragma once
#include <DataTypes/IDataType.h>
namespace DB
{
/// Dynamic type allows to store values of any type inside it and to read
/// subcolumns with any type without knowing all of them in advance.
class DataTypeDynamic final : public IDataType
{
public:
static constexpr bool is_parametric = true;
/// Don't change this constant, it can break backward compatibility.
static constexpr size_t DEFAULT_MAX_DYNAMIC_TYPES = 32;
explicit DataTypeDynamic(size_t max_dynamic_types_ = DEFAULT_MAX_DYNAMIC_TYPES);
TypeIndex getTypeId() const override { return TypeIndex::Dynamic; }
const char * getFamilyName() const override { return "Dynamic"; }
bool isParametric() const override { return true; }
bool canBeInsideNullable() const override { return false; }
bool supportsSparseSerialization() const override { return false; }
bool canBeInsideSparseColumns() const override { return false; }
bool isComparable() const override { return true; }
MutableColumnPtr createColumn() const override;
Field getDefault() const override;
/// 2 Dynamic types with different max_dynamic_types parameters are considered as different.
bool equals(const IDataType & rhs) const override
{
if (const auto * rhs_dynamic_type = typeid_cast<const DataTypeDynamic *>(&rhs))
return max_dynamic_types == rhs_dynamic_type->max_dynamic_types;
return false;
}
bool haveSubtypes() const override { return false; }
bool hasDynamicSubcolumnsData() const override { return true; }
bool hasDynamicStructure() const override { return true; }
std::unique_ptr<SubstreamData> getDynamicSubcolumnData(std::string_view subcolumn_name, const SubstreamData & data, size_t initial_array_level, bool throw_if_null) const override;
size_t getMaxDynamicTypes() const { return max_dynamic_types; }
void updateHashImpl(SipHash & hash) const override;
private:
SerializationPtr doGetSerialization(const SerializationInfoSettings & settings) const override;
String doGetName() const override;
size_t max_dynamic_types;
};
/// Returns true if provided type is Dynamic or has Dynamic type as a nested type.
bool hasDynamicType(const DataTypePtr & type);
}