1 | #pragma once |
2 | |
3 | #include <DataTypes/DataTypeNumberBase.h> |
4 | #include <Common/IntervalKind.h> |
5 | |
6 | |
7 | namespace DB |
8 | { |
9 | |
10 | /** Data type to deal with INTERVAL in SQL (arithmetic on time intervals). |
11 | * |
12 | * Mostly the same as Int64. |
13 | * But also tagged with interval kind. |
14 | * |
15 | * Intended isage is for temporary elements in expressions, |
16 | * not for storing values in tables. |
17 | */ |
18 | class DataTypeInterval final : public DataTypeNumberBase<Int64> |
19 | { |
20 | private: |
21 | IntervalKind kind; |
22 | |
23 | public: |
24 | static constexpr bool is_parametric = true; |
25 | |
26 | IntervalKind getKind() const { return kind; } |
27 | |
28 | DataTypeInterval(IntervalKind kind_) : kind(kind_) {} |
29 | |
30 | std::string doGetName() const override { return std::string("Interval" ) + kind.toString(); } |
31 | const char * getFamilyName() const override { return "Interval" ; } |
32 | TypeIndex getTypeId() const override { return TypeIndex::Interval; } |
33 | |
34 | bool equals(const IDataType & rhs) const override; |
35 | |
36 | bool isParametric() const override { return true; } |
37 | bool cannotBeStoredInTables() const override { return true; } |
38 | bool isCategorial() const override { return false; } |
39 | }; |
40 | |
41 | } |
42 | |
43 | |