#pragma once #include #include #include #include namespace DB { /** Implements part of the IDataType interface, common to all numbers and for Date and DateTime. */ template class DataTypeNumberBase : public IDataType { static_assert(is_arithmetic_v); public: static constexpr bool is_parametric = false; static constexpr auto family_name = TypeName; static constexpr auto type_id = TypeToTypeIndex; using FieldType = T; using ColumnType = ColumnVector; const char * getFamilyName() const override { return TypeName.data(); } TypeIndex getTypeId() const override { return TypeToTypeIndex; } Field getDefault() const override; MutableColumnPtr createColumn() const override; bool isParametric() const override { return false; } bool haveSubtypes() const override { return false; } bool shouldAlignRightInPrettyFormats() const override { /// Just a number, without customizations. Counterexample: IPv4. return !custom_serialization; } bool textCanContainOnlyValidUTF8() const override { return true; } bool isComparable() const override { return true; } bool isValueRepresentedByNumber() const override { return true; } bool isValueRepresentedByInteger() const override; bool isValueRepresentedByUnsignedInteger() const override; bool isValueUnambiguouslyRepresentedInContiguousMemoryRegion() const override { return true; } bool haveMaximumSizeOfValue() const override { return true; } size_t getSizeOfValueInMemory() const override { return sizeof(T); } bool isCategorial() const override { return isValueRepresentedByInteger(); } bool canBeInsideLowCardinality() const override { return true; } SerializationPtr doGetDefaultSerialization() const override { return std::make_shared>(); } }; /// Prevent implicit template instantiation of DataTypeNumberBase for common numeric types extern template class DataTypeNumberBase; extern template class DataTypeNumberBase; extern template class DataTypeNumberBase; extern template class DataTypeNumberBase; extern template class DataTypeNumberBase; extern template class DataTypeNumberBase; extern template class DataTypeNumberBase; extern template class DataTypeNumberBase; extern template class DataTypeNumberBase; extern template class DataTypeNumberBase; extern template class DataTypeNumberBase; extern template class DataTypeNumberBase; extern template class DataTypeNumberBase; extern template class DataTypeNumberBase; }