1#pragma once
2
3#include <type_traits>
4#include <Core/Field.h>
5#include <DataTypes/DataTypeNumberBase.h>
6
7
8namespace DB
9{
10
11template <typename T>
12class DataTypeNumber final : public DataTypeNumberBase<T>
13{
14 bool equals(const IDataType & rhs) const override { return typeid(rhs) == typeid(*this); }
15
16 bool canBeUsedAsVersion() const override { return true; }
17 bool isSummable() const override { return true; }
18 bool canBeUsedInBitOperations() const override { return true; }
19 bool canBeUsedInBooleanContext() const override { return true; }
20 bool canBeInsideNullable() const override { return true; }
21
22 bool canBePromoted() const override { return true; }
23 DataTypePtr promoteNumericType() const override
24 {
25 using PromotedType = DataTypeNumber<NearestFieldType<T>>;
26 return std::make_shared<PromotedType>();
27 }
28
29public:
30 DataTypeNumber(const String & type_name_ = TypeName<T>::get()) : type_name(type_name_) {}
31
32 String doGetName() const override { return type_name; }
33private:
34 const String type_name;
35};
36
37using DataTypeUInt8 = DataTypeNumber<UInt8>;
38using DataTypeUInt16 = DataTypeNumber<UInt16>;
39using DataTypeUInt32 = DataTypeNumber<UInt32>;
40using DataTypeUInt64 = DataTypeNumber<UInt64>;
41using DataTypeInt8 = DataTypeNumber<Int8>;
42using DataTypeInt16 = DataTypeNumber<Int16>;
43using DataTypeInt32 = DataTypeNumber<Int32>;
44using DataTypeInt64 = DataTypeNumber<Int64>;
45using DataTypeFloat32 = DataTypeNumber<Float32>;
46using DataTypeFloat64 = DataTypeNumber<Float64>;
47
48}
49