2021-03-09 14:10:28 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <Core/Types.h>
|
|
|
|
#include <DataTypes/DataTypeDateTime.h>
|
|
|
|
#include <DataTypes/DataTypeDecimalBase.h>
|
|
|
|
|
|
|
|
class DateLUTImpl;
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
|
|
|
/** DateTime64 is same as DateTime, but it stores values as Int64 and has configurable sub-second part.
|
|
|
|
*
|
|
|
|
* `scale` determines number of decimal places for sub-second part of the DateTime64.
|
|
|
|
*/
|
|
|
|
class DataTypeDateTime64 final : public DataTypeDecimalBase<DateTime64>, public TimezoneMixin
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
using Base = DataTypeDecimalBase<DateTime64>;
|
|
|
|
static constexpr UInt8 default_scale = 3;
|
|
|
|
|
|
|
|
static constexpr auto family_name = "DateTime64";
|
|
|
|
static constexpr auto type_id = TypeIndex::DateTime64;
|
|
|
|
|
|
|
|
explicit DataTypeDateTime64(UInt32 scale_, const std::string & time_zone_name = "");
|
|
|
|
|
|
|
|
// reuse timezone from other DateTime/DateTime64
|
|
|
|
DataTypeDateTime64(UInt32 scale_, const TimezoneMixin & time_zone_info);
|
|
|
|
|
|
|
|
const char * getFamilyName() const override { return family_name; }
|
|
|
|
std::string doGetName() const override;
|
|
|
|
TypeIndex getTypeId() const override { return type_id; }
|
|
|
|
|
|
|
|
bool equals(const IDataType & rhs) const override;
|
|
|
|
|
|
|
|
bool canBePromoted() const override { return false; }
|
|
|
|
|
2021-05-10 12:30:52 +00:00
|
|
|
bool canBeUsedAsVersion() const override { return true; }
|
|
|
|
|
2021-03-09 14:10:28 +00:00
|
|
|
protected:
|
|
|
|
SerializationPtr doGetDefaultSerialization() const override;
|
|
|
|
};
|
|
|
|
|
2023-04-07 20:59:12 +00:00
|
|
|
inline std::string getDateTimeTimezone(const IDataType & data_type);
|
2023-04-06 00:49:39 +00:00
|
|
|
|
2021-03-09 14:10:28 +00:00
|
|
|
}
|
|
|
|
|