diff options
| author | ermolovd <[email protected]> | 2025-09-17 14:47:26 +0300 |
|---|---|---|
| committer | ermolovd <[email protected]> | 2025-09-17 15:41:40 +0300 |
| commit | 9f850526f9cea07d55a28f3cab6047074e994bac (patch) | |
| tree | b73f764928ebb4e27f1942196dba288081a5264b /library/cpp/type_info | |
| parent | 83cc51995c595f710b027094fcd4532535d1b8af (diff) | |
YT-15805: introduce tz-types into type info
#### Добавление поддержки временных типов с часовым поясом (TZ-типы) 📝
- 🧱 Добавлены новые примитивные типы для представления даты, даты-времени и меток времени с часовым поясом: `TzDate32`, `TzDatetime64`, `TzTimestamp64`.
- 🧪 В модульные тесты добавлены проверки корректности создания и идентификации новых временных типов.
- 📦 Обновлена логика сериализации/десериализации: TZ-типы отображаются в строковый формат при работе с различными протоколами (Skiff, protobuf, JSON).
- ⚠️ В местах чтения данных добавлена заглушка, которая выбрасывает исключение при попытке обработки новых типов — это временное решение до реализации полной поддержки.
- 🔧 Упрощена иерархия классов примитивных типов за счёт использования шаблона `TPrimitiveTypeBase`.
- 🗂️ Изменён подход к обработке неизвестных типов в нескольких компонентах: вместо явного перечисления всех поддерживаемых типов теперь используется `default` ветка с общим обработчиком.
---
**Оценить качество описания можно [здесь](https://nda.ya.ru/t/_MxIaV0Q7FnCMG**
<a href="https://nda.ya.ru/t/qa0kX64r7DqvtN"><font size="2">Autodescription by Code Assistant</font></a>
commit_hash:265cf034372d36f60988238e273cbfe532c2a4e5
Diffstat (limited to 'library/cpp/type_info')
| -rw-r--r-- | library/cpp/type_info/fwd.h | 9 | ||||
| -rw-r--r-- | library/cpp/type_info/type.cpp | 52 | ||||
| -rw-r--r-- | library/cpp/type_info/type.h | 151 | ||||
| -rw-r--r-- | library/cpp/type_info/type_complexity.cpp | 4 | ||||
| -rw-r--r-- | library/cpp/type_info/type_constructors.h | 9 | ||||
| -rw-r--r-- | library/cpp/type_info/type_equivalence.cpp | 15 | ||||
| -rw-r--r-- | library/cpp/type_info/type_equivalence.h | 2 | ||||
| -rw-r--r-- | library/cpp/type_info/type_factory.cpp | 24 | ||||
| -rw-r--r-- | library/cpp/type_info/type_factory.h | 21 | ||||
| -rw-r--r-- | library/cpp/type_info/type_io.cpp | 31 | ||||
| -rw-r--r-- | library/cpp/type_info/type_list.h | 6 | ||||
| -rw-r--r-- | library/cpp/type_info/ut/type_basics.cpp | 36 |
12 files changed, 323 insertions, 37 deletions
diff --git a/library/cpp/type_info/fwd.h b/library/cpp/type_info/fwd.h index 127bbbeebea..323f06af4e2 100644 --- a/library/cpp/type_info/fwd.h +++ b/library/cpp/type_info/fwd.h @@ -85,6 +85,15 @@ namespace NTi { class TTzTimestampType; using TTzTimestampTypePtr = TIntrusiveConstPtr<TTzTimestampType>; + class TTzDate32Type; + using TTzDate32TypePtr = TIntrusiveConstPtr<TTzDate32Type>; + + class TTzDatetime64Type; + using TTzDatetime64TypePtr = TIntrusiveConstPtr<TTzDatetime64Type>; + + class TTzTimestamp64Type; + using TTzTimestamp64TypePtr = TIntrusiveConstPtr<TTzTimestamp64Type>; + class TIntervalType; using TIntervalTypePtr = TIntrusiveConstPtr<TIntervalType>; diff --git a/library/cpp/type_info/type.cpp b/library/cpp/type_info/type.cpp index 9197f31f2f7..9ab150bb54d 100644 --- a/library/cpp/type_info/type.cpp +++ b/library/cpp/type_info/type.cpp @@ -1,5 +1,6 @@ #include "type.h" +#include "error.h" #include "type_factory.h" #include "type_equivalence.h" @@ -295,29 +296,6 @@ namespace NTi { { } - TBoolType::TBoolType() - : TPrimitiveType({}, EPrimitiveTypeName::Bool) - { - } - - TBoolTypePtr TBoolType::Instance() { - return InstanceRaw()->AsPtr(); - } - - const TBoolType* TBoolType::InstanceRaw() { - static auto singleton = TBoolType(); - return &singleton; - } - - const TBoolType* TBoolType::Clone(ITypeFactoryInternal& factory) const noexcept { - Y_UNUSED(factory); - return InstanceRaw(); - } - - void TBoolType::Drop(ITypeFactoryInternal& factory) noexcept { - Y_UNUSED(factory); - } - TInt8Type::TInt8Type() : TPrimitiveType({}, EPrimitiveTypeName::Int8) { @@ -1475,6 +1453,19 @@ namespace NTi { return NPrivate::GetDefaultHeapFactory()->Timestamp64(); } + TTzDate32TypePtr TzDate32() { + return NPrivate::GetDefaultHeapFactory()->TzDate32(); + } + + TTzDatetime64TypePtr TzDatetime64() { + return NPrivate::GetDefaultHeapFactory()->TzDatetime64(); + } + + TTzTimestamp64TypePtr TzTimestamp64() { + return NPrivate::GetDefaultHeapFactory()->TzTimestamp64(); + } + + TInterval64TypePtr Interval64() { return NPrivate::GetDefaultHeapFactory()->Interval64(); } @@ -1672,6 +1663,21 @@ Y_DECLARE_OUT_SPEC(, NTi::TTimestamp64Type, o, v) { o << "Timestamp64"; } +Y_DECLARE_OUT_SPEC(, NTi::TTzDate32Type, o, v) { + Y_UNUSED(v); + o << "TzDate32"; +} + +Y_DECLARE_OUT_SPEC(, NTi::TTzDatetime64Type, o, v) { + Y_UNUSED(v); + o << "TzDatetime64"; +} + +Y_DECLARE_OUT_SPEC(, NTi::TTzTimestamp64Type, o, v) { + Y_UNUSED(v); + o << "TzTimestamp64"; +} + Y_DECLARE_OUT_SPEC(, NTi::TInterval64Type, o, v) { Y_UNUSED(v); o << "Interval64"; diff --git a/library/cpp/type_info/type.h b/library/cpp/type_info/type.h index 0176e4ce237..1d2e11cfd70 100644 --- a/library/cpp/type_info/type.h +++ b/library/cpp/type_info/type.h @@ -5,7 +5,6 @@ //! Hierarchy of classes that represent types. #include "fwd.h" -#include "error.h" #include "type_list.h" #include <atomic> @@ -183,6 +182,18 @@ namespace NTi { inline TTimestamp64TypePtr AsTimestamp64() const noexcept; inline const TTimestamp64Type* AsTimestamp64Raw() const noexcept; + inline bool IsTzDate32() const noexcept; + inline TTzDate32TypePtr AsTzDate32() const noexcept; + inline const TTzDate32Type* AsTzDate32Raw() const noexcept; + + inline bool IsTzDatetime64() const noexcept; + inline TTzDatetime64TypePtr AsTzDatetime64() const noexcept; + inline const TTzDatetime64Type* AsTzDatetime64Raw() const noexcept; + + inline bool IsTzTimestamp64() const noexcept; + inline TTzTimestamp64TypePtr AsTzTimestamp64() const noexcept; + inline const TTzTimestamp64Type* AsTzTimestamp64Raw() const noexcept; + inline bool IsInterval64() const noexcept; inline TInterval64TypePtr AsInterval64() const noexcept; inline const TInterval64Type* AsInterval64Raw() const noexcept; @@ -606,28 +617,56 @@ namespace NTi { inline decltype(auto) VisitPrimitiveRaw(V&& visitor) const; }; - /// A logical type capable of holding one of the two values: true or false. - class TBoolType final: public TPrimitiveType { + template <EPrimitiveTypeName Type, typename TDerived> + class TPrimitiveTypeBase + : public TPrimitiveType + { + using TDerivedPtr = TIntrusiveConstPtr<TDerived>; friend class TType; friend class ITypeFactoryInternal; friend class ITypeFactory; friend class IPoolTypeFactory; public: - TBoolTypePtr AsPtr() const noexcept { - return const_cast<TBoolType*>(this); + + TDerivedPtr AsPtr() const noexcept { + return const_cast<TDerived*>(static_cast<const TDerived*>(this)); } - private: - explicit TBoolType(); + protected: + TPrimitiveTypeBase() + : TPrimitiveType({}, Type) + { } public: - static TBoolTypePtr Instance(); - static const TBoolType* InstanceRaw(); + static TDerivedPtr Instance() + { + return InstanceRaw()->AsPtr(); + } + + static const TDerived* InstanceRaw() + { + static auto singleton = TDerived(); + return &singleton; + } protected: - const TBoolType* Clone(ITypeFactoryInternal& factory) const noexcept; - void Drop(ITypeFactoryInternal& factory) noexcept; + const TDerived* Clone(ITypeFactoryInternal& /*factory*/) const noexcept + { + return InstanceRaw(); + } + + void Drop(ITypeFactoryInternal& /*factory*/) noexcept + { } + }; + + /// A logical type capable of holding one of the two values: true or false. + class TBoolType final: public TPrimitiveTypeBase<EPrimitiveTypeName::Bool, TBoolType> + { + protected: + TBoolType() = default; + template <EPrimitiveTypeName, typename> + friend class TPrimitiveTypeBase; }; /// A signed integer, one byte. @@ -1277,6 +1316,33 @@ namespace NTi { void Drop(ITypeFactoryInternal& factory) noexcept; }; + /// An absolute point in time in range `[-144169-01-01, 148108-01-01)`, precision up to days (Unix epoch 1970-01-01 - 0 days). + class TTzDate32Type final: public TPrimitiveTypeBase<EPrimitiveTypeName::TzDate32, TTzDate32Type> + { + protected: + TTzDate32Type() = default; + template <EPrimitiveTypeName, typename> + friend class TPrimitiveTypeBase; + }; + + /// An absolute point in time in range `[-144169-01-01, 148108-01-01)`, precision up to seconds (Unix epoch 1970-01-01 - 0 seconds). + class TTzDatetime64Type final: public TPrimitiveTypeBase<EPrimitiveTypeName::TzDatetime64, TTzDatetime64Type> + { + protected: + TTzDatetime64Type() = default; + template <EPrimitiveTypeName, typename> + friend class TPrimitiveTypeBase; + }; + + /// An absolute point in time in range `[-144169-01-01, 148108-01-01)`, precision up to milliseconds (Unix epoch 1970-01-01 - 0 milliseconds). + class TTzTimestamp64Type final: public TPrimitiveTypeBase<EPrimitiveTypeName::TzTimestamp64, TTzTimestamp64Type> + { + protected: + TTzTimestamp64Type() = default; + template <EPrimitiveTypeName, typename> + friend class TPrimitiveTypeBase; + }; + /// Signed delta between two timestamps64. class TInterval64Type final: public TPrimitiveType { friend class TType; @@ -2191,6 +2257,45 @@ namespace NTi { return static_cast<const TTimestamp64Type*>(this); } + bool TType::IsTzDate32() const noexcept { + return TypeName_ == ETypeName::TzDate32; + } + + TTzDate32TypePtr TType::AsTzDate32() const noexcept { + return AsTzDate32Raw()->AsPtr(); + } + + const TTzDate32Type* TType::AsTzDate32Raw() const noexcept { + Y_ABORT_UNLESS(IsTzDate32()); + return static_cast<const TTzDate32Type*>(this); + } + + bool TType::IsTzDatetime64() const noexcept { + return TypeName_ == ETypeName::TzDatetime64; + } + + TTzDatetime64TypePtr TType::AsTzDatetime64() const noexcept { + return AsTzDatetime64Raw()->AsPtr(); + } + + const TTzDatetime64Type* TType::AsTzDatetime64Raw() const noexcept { + Y_ABORT_UNLESS(IsTzDatetime64()); + return static_cast<const TTzDatetime64Type*>(this); + } + + bool TType::IsTzTimestamp64() const noexcept { + return TypeName_ == ETypeName::TzTimestamp64; + } + + TTzTimestamp64TypePtr TType::AsTzTimestamp64() const noexcept { + return AsTzTimestamp64Raw()->AsPtr(); + } + + const TTzTimestamp64Type* TType::AsTzTimestamp64Raw() const noexcept { + Y_ABORT_UNLESS(IsTzTimestamp64()); + return static_cast<const TTzTimestamp64Type*>(this); + } + bool TType::IsInterval64() const noexcept { return TypeName_ == ETypeName::Interval64; } @@ -2356,6 +2461,12 @@ namespace NTi { return std::forward<V>(visitor)(this->AsDatetime64()); case ETypeName::Timestamp64: return std::forward<V>(visitor)(this->AsTimestamp64()); + case ETypeName::TzDate32: + return std::forward<V>(visitor)(this->AsTzDate32()); + case ETypeName::TzDatetime64: + return std::forward<V>(visitor)(this->AsTzDatetime64()); + case ETypeName::TzTimestamp64: + return std::forward<V>(visitor)(this->AsTzTimestamp64()); case ETypeName::Interval64: return std::forward<V>(visitor)(this->AsInterval64()); case ETypeName::Void: @@ -2438,6 +2549,12 @@ namespace NTi { return std::forward<V>(visitor)(this->AsDatetime64Raw()); case ETypeName::Timestamp64: return std::forward<V>(visitor)(this->AsTimestamp64Raw()); + case ETypeName::TzDate32: + return std::forward<V>(visitor)(this->AsTzDate32Raw()); + case ETypeName::TzDatetime64: + return std::forward<V>(visitor)(this->AsTzDatetime64Raw()); + case ETypeName::TzTimestamp64: + return std::forward<V>(visitor)(this->AsTzTimestamp64Raw()); case ETypeName::Interval64: return std::forward<V>(visitor)(this->AsInterval64Raw()); case ETypeName::Void: @@ -2520,6 +2637,12 @@ namespace NTi { return std::forward<V>(visitor)(this->AsDatetime64()); case EPrimitiveTypeName::Timestamp64: return std::forward<V>(visitor)(this->AsTimestamp64()); + case EPrimitiveTypeName::TzDate32: + return std::forward<V>(visitor)(this->AsTzDate32()); + case EPrimitiveTypeName::TzDatetime64: + return std::forward<V>(visitor)(this->AsTzDatetime64()); + case EPrimitiveTypeName::TzTimestamp64: + return std::forward<V>(visitor)(this->AsTzTimestamp64()); case EPrimitiveTypeName::Interval64: return std::forward<V>(visitor)(this->AsInterval64()); } @@ -2584,6 +2707,12 @@ namespace NTi { return std::forward<V>(visitor)(this->AsDatetime64Raw()); case NTi::EPrimitiveTypeName::Timestamp64: return std::forward<V>(visitor)(this->AsTimestamp64Raw()); + case NTi::EPrimitiveTypeName::TzDate32: + return std::forward<V>(visitor)(this->AsTzDate32Raw()); + case NTi::EPrimitiveTypeName::TzDatetime64: + return std::forward<V>(visitor)(this->AsTzDatetime64Raw()); + case NTi::EPrimitiveTypeName::TzTimestamp64: + return std::forward<V>(visitor)(this->AsTzTimestamp64Raw()); case NTi::EPrimitiveTypeName::Interval64: return std::forward<V>(visitor)(this->AsInterval64Raw()); } diff --git a/library/cpp/type_info/type_complexity.cpp b/library/cpp/type_info/type_complexity.cpp index 572940bff8e..15dc36eae42 100644 --- a/library/cpp/type_info/type_complexity.cpp +++ b/library/cpp/type_info/type_complexity.cpp @@ -40,6 +40,9 @@ int ComputeTypeComplexity(const TType* type) case ETypeName::Date32: case ETypeName::Datetime64: case ETypeName::Timestamp64: + case ETypeName::TzDate32: + case ETypeName::TzDatetime64: + case ETypeName::TzTimestamp64: case ETypeName::Interval64: case ETypeName::Void: case ETypeName::Null: @@ -79,4 +82,3 @@ int ComputeTypeComplexity(const TType* type) } } // namespace NTi - diff --git a/library/cpp/type_info/type_constructors.h b/library/cpp/type_info/type_constructors.h index 50c48169a5d..4fb919c8120 100644 --- a/library/cpp/type_info/type_constructors.h +++ b/library/cpp/type_info/type_constructors.h @@ -65,6 +65,15 @@ namespace NTi { /// Create new `TzTimestamp` type using the default heap factory. TTzTimestampTypePtr TzTimestamp(); + /// Create new `TzDate32` type using the default heap factory. + TTzDate32TypePtr TzDate32(); + + /// Create new `TzDatetime64` type using the default heap factory. + TTzDatetime64TypePtr TzDatetime64(); + + /// Create new `TzTimestamp64` type using the default heap factory. + TTzTimestamp64TypePtr TzTimestamp64(); + /// Create new `Interval` type using the default heap factory. TIntervalTypePtr Interval(); diff --git a/library/cpp/type_info/type_equivalence.cpp b/library/cpp/type_info/type_equivalence.cpp index 8288782cc74..cc0ab0e9582 100644 --- a/library/cpp/type_info/type_equivalence.cpp +++ b/library/cpp/type_info/type_equivalence.cpp @@ -165,6 +165,21 @@ namespace NTi::NEq { } template <bool IgnoreHash> + bool StrictlyEqual(const TTzDate32Type&, const TTzDate32Type&) { + return true; + } + + template <bool IgnoreHash> + bool StrictlyEqual(const TTzDatetime64Type&, const TTzDatetime64Type&) { + return true; + } + + template <bool IgnoreHash> + bool StrictlyEqual(const TTzTimestamp64Type&, const TTzTimestamp64Type&) { + return true; + } + + template <bool IgnoreHash> bool StrictlyEqual(const TInterval64Type&, const TInterval64Type&) { return true; } diff --git a/library/cpp/type_info/type_equivalence.h b/library/cpp/type_info/type_equivalence.h index 70351dc689c..0ede7b853d9 100644 --- a/library/cpp/type_info/type_equivalence.h +++ b/library/cpp/type_info/type_equivalence.h @@ -9,8 +9,6 @@ //! //! At the moment, only strict equivalence is implemented because others are not yet standartized. -#include <type_traits> - #include "fwd.h" #include <util/system/types.h> diff --git a/library/cpp/type_info/type_factory.cpp b/library/cpp/type_info/type_factory.cpp index 661e31c7a90..80ea9268def 100644 --- a/library/cpp/type_info/type_factory.cpp +++ b/library/cpp/type_info/type_factory.cpp @@ -241,6 +241,30 @@ namespace NTi { return TTimestamp64Type::InstanceRaw(); } + TTzDate32TypePtr ITypeFactory::TzDate32() { + return TTzDate32Type::Instance(); + } + + const TTzDate32Type* IPoolTypeFactory::TzDate32Raw() { + return TTzDate32Type::InstanceRaw(); + } + + TTzDatetime64TypePtr ITypeFactory::TzDatetime64() { + return TTzDatetime64Type::Instance(); + } + + const TTzDatetime64Type* IPoolTypeFactory::TzDatetime64Raw() { + return TTzDatetime64Type::InstanceRaw(); + } + + TTzTimestamp64TypePtr ITypeFactory::TzTimestamp64() { + return TTzTimestamp64Type::Instance(); + } + + const TTzTimestamp64Type* IPoolTypeFactory::TzTimestamp64Raw() { + return TTzTimestamp64Type::InstanceRaw(); + } + TInterval64TypePtr ITypeFactory::Interval64() { return TInterval64Type::Instance(); } diff --git a/library/cpp/type_info/type_factory.h b/library/cpp/type_info/type_factory.h index 567a164235c..c14b3354035 100644 --- a/library/cpp/type_info/type_factory.h +++ b/library/cpp/type_info/type_factory.h @@ -635,6 +635,15 @@ namespace NTi { /// Create a new `Timestamp64` type. See `NTi::TTimestamp64Type` for more info. TTimestamp64TypePtr Timestamp64(); + /// Create a new `TzDate32` type. See `NTi::TTzDate32Type` for more info. + TTzDate32TypePtr TzDate32(); + + /// Create a new `TzDatetime64` type. See `NTi::TTzDatetime64Type` for more info. + TTzDatetime64TypePtr TzDatetime64(); + + /// Create a new `TzTimestamp64` type. See `NTi::TTzTimestamp64Type` for more info. + TTzTimestamp64TypePtr TzTimestamp64(); + /// Create a new `Interval64` type. See `NTi::TInterval64Type` for more info. TInterval64TypePtr Interval64(); @@ -836,6 +845,18 @@ namespace NTi { /// The returned object will live for as long as this factory lives. const TTimestamp64Type* Timestamp64Raw(); + /// Create a new `TzDate32` type. See `NTi::TTzDate32Type` for more info. + /// The returned object will live for as long as this factory lives. + const TTzDate32Type* TzDate32Raw(); + + /// Create a new `TzDatetime64` type. See `NTi::TTzDatetime64Type` for more info. + /// The returned object will live for as long as this factory lives. + const TTzDatetime64Type* TzDatetime64Raw(); + + /// Create a new `TzTimestamp64` type. See `NTi::TTzTimestamp64Type` for more info. + /// The returned object will live for as long as this factory lives. + const TTzTimestamp64Type* TzTimestamp64Raw(); + /// Create a new `Interval64` type. See `NTi::TInterval64Type` for more info. /// The returned object will live for as long as this factory lives. const TInterval64Type* Interval64Raw(); diff --git a/library/cpp/type_info/type_io.cpp b/library/cpp/type_info/type_io.cpp index f397466abce..0d50045a2f0 100644 --- a/library/cpp/type_info/type_io.cpp +++ b/library/cpp/type_info/type_io.cpp @@ -1,6 +1,7 @@ #include "type_io.h" #include "builder.h" +#include "error.h" #include "type_constructors.h" #include "type_factory.h" @@ -309,6 +310,15 @@ namespace NTi::NIo { type = TDatetime64Type::InstanceRaw(); break; case ETypeName::Timestamp64: + type = TTzTimestamp64Type::InstanceRaw(); + break; + case ETypeName::TzDate32: + type = TTzDate32Type::InstanceRaw(); + break; + case ETypeName::TzDatetime64: + type = TTzDatetime64Type::InstanceRaw(); + break; + case ETypeName::TzTimestamp64: type = TTimestamp64Type::InstanceRaw(); break; case ETypeName::Interval64: @@ -746,6 +756,15 @@ namespace NTi::NIo { [&consumer](const TTimestamp64Type*) { consumer.OnScalarString("timestamp64"); }, + [&consumer](const TTzDate32Type*) { + consumer.OnScalarString("tz_date32"); + }, + [&consumer](const TTzDatetime64Type*) { + consumer.OnScalarString("tz_datetime64"); + }, + [&consumer](const TTzTimestamp64Type*) { + consumer.OnScalarString("tz_timestamp64"); + }, [&consumer](const TInterval64Type*) { consumer.OnScalarString("interval64"); }, @@ -1016,6 +1035,15 @@ namespace NTi::NIo { [&consumer](const TTimestamp64Type*) { WriteDataType(consumer, EPrimitiveTypeName::Timestamp64); }, + [&consumer](const TTzDate32Type*) { + WriteDataType(consumer, EPrimitiveTypeName::TzDate32); + }, + [&consumer](const TTzDatetime64Type*) { + WriteDataType(consumer, EPrimitiveTypeName::TzDatetime64); + }, + [&consumer](const TTzTimestamp64Type*) { + WriteDataType(consumer, EPrimitiveTypeName::TzTimestamp64); + }, [&consumer](const TInterval64Type*) { WriteDataType(consumer, EPrimitiveTypeName::Interval64); }, @@ -1196,6 +1224,9 @@ namespace NTi::NIo { [](const TDate32Type*) -> TStringBuf { return "int64"; }, [](const TDatetime64Type*) -> TStringBuf { return "int64"; }, [](const TTimestamp64Type*) -> TStringBuf { return "int64"; }, + [](const TTzDate32Type*) -> TStringBuf { return "string"; }, + [](const TTzDatetime64Type*) -> TStringBuf { return "string"; }, + [](const TTzTimestamp64Type*) -> TStringBuf { return "string"; }, [](const TInterval64Type*) -> TStringBuf { return "int64"; }, [](const TDecimalType*) -> TStringBuf { return "string"; }, [](const TOptionalType*) -> TStringBuf { return "any"; }, diff --git a/library/cpp/type_info/type_list.h b/library/cpp/type_info/type_list.h index 2a4d13c27f7..5da39ae1444 100644 --- a/library/cpp/type_info/type_list.h +++ b/library/cpp/type_info/type_list.h @@ -63,6 +63,9 @@ namespace NTi { Date32, Datetime64, Timestamp64, + TzDate32, + TzDatetime64, + TzTimestamp64, Interval64, }; @@ -106,6 +109,9 @@ namespace NTi { Date32, Datetime64, Timestamp64, + TzDate32, + TzDatetime64, + TzTimestamp64, Interval64, FIRST_PRIMITIVE = Bool, diff --git a/library/cpp/type_info/ut/type_basics.cpp b/library/cpp/type_info/ut/type_basics.cpp index 83996d63d3b..771e4ffa7d0 100644 --- a/library/cpp/type_info/ut/type_basics.cpp +++ b/library/cpp/type_info/ut/type_basics.cpp @@ -124,6 +124,42 @@ TEST_TF(TypeBasics, TzTimestamp) { ASSERT_TRUE(t->IsTzTimestamp()); } +TEST_TF(TypeBasics, Date32) { + auto t = f.Date32(); + ASSERT_EQ(t->GetTypeName(), NTi::ETypeName::Date32); + ASSERT_TRUE(t->IsDate32()); +} + +TEST_TF(TypeBasics, Datetime64) { + auto t = f.Datetime64(); + ASSERT_EQ(t->GetTypeName(), NTi::ETypeName::Datetime64); + ASSERT_TRUE(t->IsDatetime64()); +} + +TEST_TF(TypeBasics, Timestamp64) { + auto t = f.Timestamp64(); + ASSERT_EQ(t->GetTypeName(), NTi::ETypeName::Timestamp64); + ASSERT_TRUE(t->IsTimestamp64()); +} + +TEST_TF(TypeBasics, TzDate32) { + auto t = f.TzDate32(); + ASSERT_EQ(t->GetTypeName(), NTi::ETypeName::TzDate32); + ASSERT_TRUE(t->IsTzDate32()); +} + +TEST_TF(TypeBasics, TzDatetime64) { + auto t = f.TzDatetime64(); + ASSERT_EQ(t->GetTypeName(), NTi::ETypeName::TzDatetime64); + ASSERT_TRUE(t->IsTzDatetime64()); +} + +TEST_TF(TypeBasics, TzTimestamp64) { + auto t = f.TzTimestamp64(); + ASSERT_EQ(t->GetTypeName(), NTi::ETypeName::TzTimestamp64); + ASSERT_TRUE(t->IsTzTimestamp64()); +} + TEST_TF(TypeBasics, Interval) { auto t = f.Interval(); ASSERT_EQ(t->GetTypeName(), NTi::ETypeName::Interval); |
