2017-10-30 02:18:06 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <DataTypes/DataTypeNumberBase.h>
|
2019-11-16 13:54:52 +00:00
|
|
|
#include <Common/IntervalKind.h>
|
2017-10-30 02:18:06 +00:00
|
|
|
|
|
|
|
|
|
|
|
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,
|
2017-10-30 02:18:06 +00:00
|
|
|
* not for storing values in tables.
|
|
|
|
*/
|
|
|
|
class DataTypeInterval final : public DataTypeNumberBase<Int64>
|
|
|
|
{
|
|
|
|
private:
|
2019-11-16 13:54:52 +00:00
|
|
|
IntervalKind kind;
|
2017-10-30 02:18:06 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
static constexpr bool is_parametric = true;
|
|
|
|
|
2019-11-16 13:54:52 +00:00
|
|
|
IntervalKind getKind() const { return kind; }
|
2017-10-30 02:18:06 +00:00
|
|
|
|
2022-03-12 17:46:38 +00:00
|
|
|
explicit DataTypeInterval(IntervalKind kind_) : kind(kind_) {}
|
2017-10-30 02:18:06 +00:00
|
|
|
|
2021-09-06 14:24:03 +00:00
|
|
|
std::string doGetName() const override { return fmt::format("Interval{}", kind.toString()); }
|
2017-10-30 02:18:06 +00:00
|
|
|
const char * getFamilyName() const override { return "Interval"; }
|
2018-09-07 14:37:26 +00:00
|
|
|
TypeIndex getTypeId() const override { return TypeIndex::Interval; }
|
2017-10-30 02:18:06 +00:00
|
|
|
|
2017-12-23 01:05:29 +00:00
|
|
|
bool equals(const IDataType & rhs) const override;
|
|
|
|
|
2017-12-09 06:32:22 +00:00
|
|
|
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; }
|
2017-10-30 02:18:06 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|