ClickHouse/src/DataTypes/DataTypeInterval.h

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

44 lines
1.2 KiB
C++
Raw Normal View History

#pragma once
#include <DataTypes/DataTypeNumberBase.h>
#include <Common/IntervalKind.h>
namespace DB
{
/** Data type to deal with INTERVAL in SQL (arithmetic on time intervals).
*
* Mostly the same as Int64.
* But also tagged with interval kind.
*
2020-02-01 21:22:00 +00:00
* Intended usage is for temporary elements in expressions,
* not for storing values in tables.
*/
class DataTypeInterval final : public DataTypeNumberBase<Int64>
{
private:
IntervalKind kind;
public:
static constexpr bool is_parametric = true;
IntervalKind getKind() const { return kind; }
explicit DataTypeInterval(IntervalKind kind_) : kind(kind_) {}
std::string doGetName() const override { return fmt::format("Interval{}", kind.toString()); }
const char * getFamilyName() const override { return "Interval"; }
TypeIndex getTypeId() const override { return TypeIndex::Interval; }
bool equals(const IDataType & rhs) const override;
bool isParametric() const override { return true; }
bool cannotBeStoredInTables() const override { return true; }
bool isCategorial() const override { return false; }
2021-07-19 12:35:55 +00:00
bool canBeInsideNullable() const override { return true; }
};
}