diff options
| author | Vitaly Stoyan <[email protected]> | 2024-06-17 16:42:38 +0300 |
|---|---|---|
| committer | GitHub <[email protected]> | 2024-06-17 16:42:38 +0300 |
| commit | aa4673dfc6b3752a416860ceb47480fe1cea4ff9 (patch) | |
| tree | a3177d844aecdf62ee665b6f2e84c4692785cac9 | |
| parent | 3fbd1cc9396c749400b8fbda52431148392fff4a (diff) | |
Introduced bigger tz types (#5584)
18 files changed, 268 insertions, 1 deletions
diff --git a/ydb/library/yql/dq/runtime/dq_arrow_helpers.cpp b/ydb/library/yql/dq/runtime/dq_arrow_helpers.cpp index 7e6e59ea56a..5ed47b9aea6 100644 --- a/ydb/library/yql/dq/runtime/dq_arrow_helpers.cpp +++ b/ydb/library/yql/dq/runtime/dq_arrow_helpers.cpp @@ -96,6 +96,9 @@ bool SwitchMiniKQLDataTypeToArrowType(NUdf::EDataSlot type, TFunc&& callback) { case NUdf::EDataSlot::TzDate: case NUdf::EDataSlot::TzDatetime: case NUdf::EDataSlot::TzTimestamp: + case NUdf::EDataSlot::TzDate32: + case NUdf::EDataSlot::TzDatetime64: + case NUdf::EDataSlot::TzTimestamp64: return false; } } diff --git a/ydb/library/yql/dq/runtime/dq_transport.cpp b/ydb/library/yql/dq/runtime/dq_transport.cpp index 53900bd85b8..24f33f20d16 100644 --- a/ydb/library/yql/dq/runtime/dq_transport.cpp +++ b/ydb/library/yql/dq/runtime/dq_transport.cpp @@ -210,7 +210,10 @@ std::optional<ui64> EstimateIntegralDataSize(const TDataType* dataType) { case NUdf::EDataSlot::Datetime64: case NUdf::EDataSlot::Timestamp64: case NUdf::EDataSlot::Interval64: + case NUdf::EDataSlot::TzDate32: return 8; + case NUdf::EDataSlot::TzDatetime64: + case NUdf::EDataSlot::TzTimestamp64: case NUdf::EDataSlot::Uuid: case NUdf::EDataSlot::Decimal: return 16; diff --git a/ydb/library/yql/dq/type_ann/dq_type_ann.cpp b/ydb/library/yql/dq/type_ann/dq_type_ann.cpp index ed621ed4726..f651c15c6bf 100644 --- a/ydb/library/yql/dq/type_ann/dq_type_ann.cpp +++ b/ydb/library/yql/dq/type_ann/dq_type_ann.cpp @@ -1134,6 +1134,9 @@ bool IsTypeSupportedInMergeCn(EDataSlot type) { case EDataSlot::Datetime64: case EDataSlot::Timestamp64: case EDataSlot::Interval64: + case EDataSlot::TzDate32: + case EDataSlot::TzDatetime64: + case EDataSlot::TzTimestamp64: return false; } return false; diff --git a/ydb/library/yql/minikql/computation/mkql_computation_node_pack.cpp b/ydb/library/yql/minikql/computation/mkql_computation_node_pack.cpp index a4703b83919..0ebec224269 100644 --- a/ydb/library/yql/minikql/computation/mkql_computation_node_pack.cpp +++ b/ydb/library/yql/minikql/computation/mkql_computation_node_pack.cpp @@ -339,6 +339,21 @@ NUdf::TUnboxedValue UnpackFromChunkedBuffer(const TType* type, TChunkedInputBuff ret.SetTimezoneId(UnpackData<Fast, ui16>(buf)); return ret; } + case NUdf::EDataSlot::TzDate32: { + auto ret = NUdf::TUnboxedValuePod(UnpackData<Fast, i32>(buf)); + ret.SetTimezoneId(UnpackData<Fast, ui16>(buf)); + return ret; + } + case NUdf::EDataSlot::TzDatetime64: { + auto ret = NUdf::TUnboxedValuePod(UnpackData<Fast, i64>(buf)); + ret.SetTimezoneId(UnpackData<Fast, ui16>(buf)); + return ret; + } + case NUdf::EDataSlot::TzTimestamp64: { + auto ret = NUdf::TUnboxedValuePod(UnpackData<Fast, i64>(buf)); + ret.SetTimezoneId(UnpackData<Fast, ui16>(buf)); + return ret; + } case NUdf::EDataSlot::Uuid: { return UnpackString(buf, 16); } @@ -672,6 +687,21 @@ void PackImpl(const TType* type, TBuf& buffer, const NUdf::TUnboxedValuePod& val PackData<Fast>(value.GetTimezoneId(), buffer); break; } + case NUdf::EDataSlot::TzDate32: { + PackData<Fast>(value.Get<i32>(), buffer); + PackData<Fast>(value.GetTimezoneId(), buffer); + break; + } + case NUdf::EDataSlot::TzDatetime64: { + PackData<Fast>(value.Get<i64>(), buffer); + PackData<Fast>(value.GetTimezoneId(), buffer); + break; + } + case NUdf::EDataSlot::TzTimestamp64: { + PackData<Fast>(value.Get<i64>(), buffer); + PackData<Fast>(value.GetTimezoneId(), buffer); + break; + } case NUdf::EDataSlot::Decimal: { PackDecimal(value.GetInt128(), buffer); break; diff --git a/ydb/library/yql/minikql/mkql_type_builder.cpp b/ydb/library/yql/minikql/mkql_type_builder.cpp index 15418d8f3d7..1ff5707aa11 100644 --- a/ydb/library/yql/minikql/mkql_type_builder.cpp +++ b/ydb/library/yql/minikql/mkql_type_builder.cpp @@ -1483,6 +1483,18 @@ bool ConvertArrowType(NUdf::EDataSlot slot, std::shared_ptr<arrow::DataType>& ty type = MakeTzDateArrowType<NYql::NUdf::EDataSlot::TzTimestamp>(); return true; } + case NUdf::EDataSlot::TzDate32: { + type = MakeTzDateArrowType<NYql::NUdf::EDataSlot::TzDate32>(); + return true; + } + case NUdf::EDataSlot::TzDatetime64: { + type = MakeTzDateArrowType<NYql::NUdf::EDataSlot::TzDatetime64>(); + return true; + } + case NUdf::EDataSlot::TzTimestamp64: { + type = MakeTzDateArrowType<NYql::NUdf::EDataSlot::TzTimestamp64>(); + return true; + } case NUdf::EDataSlot::Uuid: { return false; } @@ -2456,6 +2468,12 @@ size_t CalcMaxBlockItemSize(const TType* type) { return sizeof(typename NUdf::TDataType<NUdf::TTzDatetime>::TLayout) + sizeof(NYql::NUdf::TTimezoneId); case NUdf::EDataSlot::TzTimestamp: return sizeof(typename NUdf::TDataType<NUdf::TTzTimestamp>::TLayout) + sizeof(NYql::NUdf::TTimezoneId); + case NUdf::EDataSlot::TzDate32: + return sizeof(typename NUdf::TDataType<NUdf::TTzDate32>::TLayout) + sizeof(NYql::NUdf::TTimezoneId); + case NUdf::EDataSlot::TzDatetime64: + return sizeof(typename NUdf::TDataType<NUdf::TTzDatetime64>::TLayout) + sizeof(NYql::NUdf::TTimezoneId); + case NUdf::EDataSlot::TzTimestamp64: + return sizeof(typename NUdf::TDataType<NUdf::TTzTimestamp64>::TLayout) + sizeof(NYql::NUdf::TTimezoneId); case NUdf::EDataSlot::Uuid: { MKQL_ENSURE(false, "Unsupported data slot: " << slot); } diff --git a/ydb/library/yql/minikql/mkql_type_builder.h b/ydb/library/yql/minikql/mkql_type_builder.h index 56e65b5c6f9..7679afdb135 100644 --- a/ydb/library/yql/minikql/mkql_type_builder.h +++ b/ydb/library/yql/minikql/mkql_type_builder.h @@ -35,7 +35,8 @@ bool ConvertArrowType(NUdf::EDataSlot slot, std::shared_ptr<arrow::DataType>& ty template<NUdf::EDataSlot slot> std::shared_ptr<arrow::DataType> MakeTzLayoutArrowType() { - static_assert(slot == NUdf::EDataSlot::TzDate || slot == NUdf::EDataSlot::TzDatetime || slot == NUdf::EDataSlot::TzTimestamp, + static_assert(slot == NUdf::EDataSlot::TzDate || slot == NUdf::EDataSlot::TzDatetime || slot == NUdf::EDataSlot::TzTimestamp + || slot == NUdf::EDataSlot::TzDate32 || slot == NUdf::EDataSlot::TzDatetime64 || slot == NUdf::EDataSlot::TzTimestamp64, "Expected tz date type slot"); if constexpr (slot == NUdf::EDataSlot::TzDate) { @@ -47,6 +48,15 @@ std::shared_ptr<arrow::DataType> MakeTzLayoutArrowType() { if constexpr (slot == NUdf::EDataSlot::TzTimestamp) { return arrow::uint64(); } + if constexpr (slot == NUdf::EDataSlot::TzDate32) { + return arrow::int32(); + } + if constexpr (slot == NUdf::EDataSlot::TzDatetime64) { + return arrow::int64(); + } + if constexpr (slot == NUdf::EDataSlot::TzTimestamp64) { + return arrow::int64(); + } } template<NUdf::EDataSlot slot> diff --git a/ydb/library/yql/minikql/mkql_type_ops.cpp b/ydb/library/yql/minikql/mkql_type_ops.cpp index fef400eeb45..888077882ba 100644 --- a/ydb/library/yql/minikql/mkql_type_ops.cpp +++ b/ydb/library/yql/minikql/mkql_type_ops.cpp @@ -144,6 +144,15 @@ bool IsValidValue(NUdf::EDataSlot type, const NUdf::TUnboxedValuePod& value) { case NUdf::EDataSlot::TzTimestamp: return bool(value) && value.Get<ui64>() < NUdf::MAX_TIMESTAMP && value.GetTimezoneId() < NUdf::GetTimezones().size(); + case NUdf::EDataSlot::TzDate32: + return bool(value) && value.Get<i32>() >= NUdf::MIN_DATE32 && value.Get<i32>() <= NUdf::MAX_DATE32 && value.GetTimezoneId() < NUdf::GetTimezones().size(); + + case NUdf::EDataSlot::TzDatetime64: + return bool(value) && value.Get<i64>() >= NUdf::MIN_DATETIME64 && value.Get<i64>() <= NUdf::MAX_DATETIME64 && value.GetTimezoneId() < NUdf::GetTimezones().size(); + + case NUdf::EDataSlot::TzTimestamp64: + return bool(value) && value.Get<i64>() >= NUdf::MIN_TIMESTAMP64 && value.Get<i64>() <= NUdf::MAX_TIMESTAMP64 && value.GetTimezoneId() < NUdf::GetTimezones().size(); + case NUdf::EDataSlot::Utf8: return bool(value) && IsUtf8(value.AsStringRef()); case NUdf::EDataSlot::Yson: @@ -2278,6 +2287,9 @@ NUdf::TUnboxedValuePod SimpleValueFromYson(NUdf::EDataSlot type, NUdf::TStringRe case NUdf::EDataSlot::TzDate: case NUdf::EDataSlot::TzDatetime: case NUdf::EDataSlot::TzTimestamp: + case NUdf::EDataSlot::TzDate32: + case NUdf::EDataSlot::TzDatetime64: + case NUdf::EDataSlot::TzTimestamp64: case NUdf::EDataSlot::Decimal: case NUdf::EDataSlot::Uuid: case NUdf::EDataSlot::DyNumber: @@ -2448,5 +2460,86 @@ bool DeserializeTzTimestamp(TStringBuf buf, ui64& timestamp, ui16& tzId) { return true; } +void SerializeTzDate32(i32 date, ui16 tzId, IOutputStream& out) { + date = SwapBytes(date); + tzId = SwapBytes(tzId); + out.Write(&date, sizeof(date)); + out.Write(&tzId, sizeof(tzId)); +} + +void SerializeTzDatetime64(i64 datetime, ui16 tzId, IOutputStream& out) { + datetime = SwapBytes(datetime); + tzId = SwapBytes(tzId); + out.Write(&datetime, sizeof(datetime)); + out.Write(&tzId, sizeof(tzId)); +} + +void SerializeTzTimestamp64(i64 timestamp, ui16 tzId, IOutputStream& out) { + timestamp = SwapBytes(timestamp); + tzId = SwapBytes(tzId); + out.Write(×tamp, sizeof(timestamp)); + out.Write(&tzId, sizeof(tzId)); +} + +bool DeserializeTzDate32(TStringBuf buf, i32& date, ui16& tzId) { + if (buf.size() != sizeof(i32) + sizeof(ui16)) { + return false; + } + + date = ReadUnaligned<i32>(buf.data()); + date = SwapBytes(date); + if (date < NUdf::MIN_DATE32 || date > NUdf::MAX_DATE32) { + return false; + } + + tzId = ReadUnaligned<ui16>(buf.data() + sizeof(date)); + tzId = SwapBytes(tzId); + if (!IsValidTimezoneId(tzId)) { + return false; + } + + return true; +} + +bool DeserializeTzDatetime64(TStringBuf buf, i64& datetime, ui16& tzId) { + if (buf.size() != sizeof(i64) + sizeof(ui16)) { + return false; + } + + datetime = ReadUnaligned<i64>(buf.data()); + datetime = SwapBytes(datetime); + if (datetime < NUdf::MIN_DATETIME64 || datetime > NUdf::MAX_DATETIME64) { + return false; + } + + tzId = ReadUnaligned<ui16>(buf.data() + sizeof(datetime)); + tzId = SwapBytes(tzId); + if (!IsValidTimezoneId(tzId)) { + return false; + } + + return true; +} + +bool DeserializeTzTimestamp64(TStringBuf buf, i64& timestamp, ui16& tzId) { + if (buf.size() != sizeof(i64) + sizeof(ui16)) { + return false; + } + + timestamp = ReadUnaligned<i64>(buf.data()); + timestamp = SwapBytes(timestamp); + if (timestamp < NUdf::MIN_TIMESTAMP64 || timestamp > NUdf::MAX_TIMESTAMP64) { + return false; + } + + tzId = ReadUnaligned<ui16>(buf.data() + sizeof(timestamp)); + tzId = SwapBytes(tzId); + if (!IsValidTimezoneId(tzId)) { + return false; + } + + return true; +} + } // namespace NMiniKQL } // namespace NKikimr diff --git a/ydb/library/yql/minikql/mkql_type_ops.h b/ydb/library/yql/minikql/mkql_type_ops.h index 5e2cafd4ec3..c01f34add06 100644 --- a/ydb/library/yql/minikql/mkql_type_ops.h +++ b/ydb/library/yql/minikql/mkql_type_ops.h @@ -65,5 +65,12 @@ void SerializeTzTimestamp(ui64 timestamp, ui16 tzId, IOutputStream& out); bool DeserializeTzDate(TStringBuf buf, ui16& date, ui16& tzId); bool DeserializeTzDatetime(TStringBuf buf, ui32& datetime, ui16& tzId); bool DeserializeTzTimestamp(TStringBuf buf, ui64& timestamp, ui16& tzId); + +void SerializeTzDate32(i32 date, ui16 tzId, IOutputStream& out); +void SerializeTzDatetime64(i64 datetime, ui16 tzId, IOutputStream& out); +void SerializeTzTimestamp64(i64 timestamp, ui16 tzId, IOutputStream& out); +bool DeserializeTzDate32(TStringBuf buf, i32& date, ui16& tzId); +bool DeserializeTzDatetime64(TStringBuf buf, i64& datetime, ui16& tzId); +bool DeserializeTzTimestamp64(TStringBuf buf, i64& timestamp, ui16& tzId); } // namespace NMiniKQL } // namespace NKikimr diff --git a/ydb/library/yql/parser/pg_wrapper/comp_factory.cpp b/ydb/library/yql/parser/pg_wrapper/comp_factory.cpp index fbc2f7c48c8..e5e90d35466 100644 --- a/ydb/library/yql/parser/pg_wrapper/comp_factory.cpp +++ b/ydb/library/yql/parser/pg_wrapper/comp_factory.cpp @@ -4075,6 +4075,12 @@ ui32 ConvertToPgType(NUdf::EDataSlot slot) { return TIMESTAMPOID; case NUdf::EDataSlot::Interval64: return INTERVALOID; + case NUdf::EDataSlot::TzDate32: + return TEXTOID; + case NUdf::EDataSlot::TzDatetime64: + return TEXTOID; + case NUdf::EDataSlot::TzTimestamp64: + return TEXTOID; } } diff --git a/ydb/library/yql/providers/common/codec/yql_codec.cpp b/ydb/library/yql/providers/common/codec/yql_codec.cpp index 5634843806d..9dc16a4d588 100644 --- a/ydb/library/yql/providers/common/codec/yql_codec.cpp +++ b/ydb/library/yql/providers/common/codec/yql_codec.cpp @@ -494,6 +494,22 @@ TString DataValueToString(const NKikimr::NUdf::TUnboxedValuePod& value, const TD out << value.Get<ui64>() << "," << NKikimr::NMiniKQL::GetTimezoneIANAName(value.GetTimezoneId()); return out.Str(); } + case NUdf::EDataSlot::TzDate32: { + TStringStream out; + out << value.Get<i32>() << "," << NKikimr::NMiniKQL::GetTimezoneIANAName(value.GetTimezoneId()); + return out.Str(); + } + case NUdf::EDataSlot::TzDatetime64: { + TStringStream out; + out << value.Get<i64>() << "," << NKikimr::NMiniKQL::GetTimezoneIANAName(value.GetTimezoneId()); + return out.Str(); + } + case NUdf::EDataSlot::TzTimestamp64: { + TStringStream out; + out << value.Get<i64>() << "," << NKikimr::NMiniKQL::GetTimezoneIANAName(value.GetTimezoneId()); + return out.Str(); + } + case NUdf::EDataSlot::JsonDocument: { NUdf::TUnboxedValue json = ValueToString(EDataSlot::JsonDocument, value); return ToString(TStringBuf(value.AsStringRef())); diff --git a/ydb/library/yql/providers/common/schema/skiff/yql_skiff_schema.cpp b/ydb/library/yql/providers/common/schema/skiff/yql_skiff_schema.cpp index 467ec4d2013..294d69d3af9 100644 --- a/ydb/library/yql/providers/common/schema/skiff/yql_skiff_schema.cpp +++ b/ydb/library/yql/providers/common/schema/skiff/yql_skiff_schema.cpp @@ -79,6 +79,9 @@ struct TSkiffTypeLoader { case NUdf::EDataSlot::TzDate: case NUdf::EDataSlot::TzDatetime: case NUdf::EDataSlot::TzTimestamp: + case NUdf::EDataSlot::TzDate32: + case NUdf::EDataSlot::TzDatetime64: + case NUdf::EDataSlot::TzTimestamp64: return NYT::TNode()("wire_type", "string32"); case NUdf::EDataSlot::Decimal: ythrow yexception() << "Decimal type without parameters."; diff --git a/ydb/library/yql/providers/yt/comp_nodes/dq/arrow_converter.cpp b/ydb/library/yql/providers/yt/comp_nodes/dq/arrow_converter.cpp index f1b7e038475..b438e139359 100644 --- a/ydb/library/yql/providers/yt/comp_nodes/dq/arrow_converter.cpp +++ b/ydb/library/yql/providers/yt/comp_nodes/dq/arrow_converter.cpp @@ -345,6 +345,12 @@ public: DeserializeTzDatetime({buf.Data(), length}, date, tz); } else if constexpr (std::is_same_v<T, NUdf::TTzTimestamp>) { DeserializeTzTimestamp({buf.Data(), length}, date, tz); + } else if constexpr (std::is_same_v<T, NUdf::TTzDate32>) { + DeserializeTzDate32({buf.Data(), length}, date, tz); + } else if constexpr (std::is_same_v<T, NUdf::TTzDatetime64>) { + DeserializeTzDatetime64({buf.Data(), length}, date, tz); + } else if constexpr (std::is_same_v<T, NUdf::TTzTimestamp64>) { + DeserializeTzTimestamp64({buf.Data(), length}, date, tz); } else { static_assert(sizeof(T) == 0, "Unsupported tz date type"); } diff --git a/ydb/library/yql/providers/yt/lib/expr_traits/yql_expr_traits.cpp b/ydb/library/yql/providers/yt/lib/expr_traits/yql_expr_traits.cpp index 300bd35a1be..f57d826e079 100644 --- a/ydb/library/yql/providers/yt/lib/expr_traits/yql_expr_traits.cpp +++ b/ydb/library/yql/providers/yt/lib/expr_traits/yql_expr_traits.cpp @@ -236,6 +236,9 @@ namespace NYql { case EDataSlot::TzDate: case EDataSlot::TzDatetime: case EDataSlot::TzTimestamp: + case EDataSlot::TzDate32: + case EDataSlot::TzDatetime64: + case EDataSlot::TzTimestamp64: case EDataSlot::DyNumber: case EDataSlot::JsonDocument: break; diff --git a/ydb/library/yql/public/types/yql_types.proto b/ydb/library/yql/public/types/yql_types.proto index a14b347f184..32dfcbd1b4a 100644 --- a/ydb/library/yql/public/types/yql_types.proto +++ b/ydb/library/yql/public/types/yql_types.proto @@ -32,6 +32,9 @@ enum TypeIds { Datetime64 = 0x0041; Timestamp64 = 0x0042; Interval64 = 0x0043; + TzDate32 = 0x0044; + TzDatetime64 = 0x0045; + TzTimestamp64 = 0x0046; Decimal = 0x1301; DyNumber = 0x1302; } diff --git a/ydb/library/yql/public/udf/arrow/block_builder.h b/ydb/library/yql/public/udf/arrow/block_builder.h index 7ac7ffa6b14..2f46532de71 100644 --- a/ydb/library/yql/public/udf/arrow/block_builder.h +++ b/ydb/library/yql/public/udf/arrow/block_builder.h @@ -1416,6 +1416,12 @@ inline std::unique_ptr<TArrayBuilderBase> MakeArrayBuilderImpl( return std::make_unique<TTzDateArrayBuilder<TTzDatetime, Nullable>>(typeInfoHelper, type, pool, maxLen); case NUdf::EDataSlot::TzTimestamp: return std::make_unique<TTzDateArrayBuilder<TTzTimestamp, Nullable>>(typeInfoHelper, type, pool, maxLen); + case NUdf::EDataSlot::TzDate32: + return std::make_unique<TTzDateArrayBuilder<TTzDate32, Nullable>>(typeInfoHelper, type, pool, maxLen); + case NUdf::EDataSlot::TzDatetime64: + return std::make_unique<TTzDateArrayBuilder<TTzDatetime64, Nullable>>(typeInfoHelper, type, pool, maxLen); + case NUdf::EDataSlot::TzTimestamp64: + return std::make_unique<TTzDateArrayBuilder<TTzTimestamp64, Nullable>>(typeInfoHelper, type, pool, maxLen); default: Y_ENSURE(false, "Unsupported data slot"); } diff --git a/ydb/library/yql/public/udf/arrow/block_reader.h b/ydb/library/yql/public/udf/arrow/block_reader.h index 3eaeb62f73e..bac76df5afe 100644 --- a/ydb/library/yql/public/udf/arrow/block_reader.h +++ b/ydb/library/yql/public/udf/arrow/block_reader.h @@ -654,6 +654,12 @@ std::unique_ptr<typename TTraits::TResult> MakeBlockReaderImpl(const ITypeInfoHe return TTraits::template MakeTzDate<TTzDatetime>(isOptional); case NUdf::EDataSlot::TzTimestamp: return TTraits::template MakeTzDate<TTzTimestamp>(isOptional); + case NUdf::EDataSlot::TzDate32: + return TTraits::template MakeTzDate<TTzDate32>(isOptional); + case NUdf::EDataSlot::TzDatetime64: + return TTraits::template MakeTzDate<TTzDatetime64>(isOptional); + case NUdf::EDataSlot::TzTimestamp64: + return TTraits::template MakeTzDate<TTzTimestamp64>(isOptional); case NUdf::EDataSlot::Uuid: case NUdf::EDataSlot::Decimal: case NUdf::EDataSlot::DyNumber: diff --git a/ydb/library/yql/public/udf/udf_data_type.h b/ydb/library/yql/public/udf/udf_data_type.h index 476c3c313eb..439091d929e 100644 --- a/ydb/library/yql/public/udf/udf_data_type.h +++ b/ydb/library/yql/public/udf/udf_data_type.h @@ -151,6 +151,9 @@ class TDate32 {}; class TDatetime64 {}; class TTimestamp64 {}; class TInterval64 {}; +class TTzDate32 {}; +class TTzDatetime64 {}; +class TTzTimestamp64 {}; class TDecimal {}; class TDyNumber {}; @@ -201,6 +204,9 @@ constexpr i32 MAX_YEAR32 = 148108; // non-inclusive XX(Datetime64, NYql::NProto::Datetime64, TDatetime64, CommonType | DateType | BigDateType, i64, 0) \ XX(Timestamp64, NYql::NProto::Timestamp64, TTimestamp64, CommonType | DateType | BigDateType, i64, 0) \ XX(Interval64, NYql::NProto::Interval64, TInterval64, CommonType | TimeIntervalType | BigDateType, i64, 0) \ + XX(TzDate32, NYql::NProto::TzDate32, TTzDate32, CommonType | TzDateType | BigDateType, i32, 0) \ + XX(TzDatetime64, NYql::NProto::TzDatetime64, TTzDatetime64, CommonType | TzDateType | BigDateType, i64, 0) \ + XX(TzTimestamp64, NYql::NProto::TzTimestamp64, TTzTimestamp64, CommonType | TzDateType | BigDateType, i64, 0) \ #define UDF_TYPE_ID(xName, xTypeId, xType, xFeatures, xLayoutType, xParamsCount) \ template <> \ diff --git a/ydb/library/yql/public/udf/udf_type_ops.h b/ydb/library/yql/public/udf/udf_type_ops.h index fff4ffab432..ac848d07c8b 100644 --- a/ydb/library/yql/public/udf/udf_type_ops.h +++ b/ydb/library/yql/public/udf/udf_type_ops.h @@ -204,6 +204,21 @@ inline THashType GetValueHash<EDataSlot::Interval64>(const TUnboxedValuePod& val } template <> +inline THashType GetValueHash<EDataSlot::TzDate32>(const TUnboxedValuePod& value) { + return GetTzIntegerHash<i32>(value); +} + +template <> +inline THashType GetValueHash<EDataSlot::TzDatetime64>(const TUnboxedValuePod& value) { + return GetTzIntegerHash<i64>(value); +} + +template <> +inline THashType GetValueHash<EDataSlot::TzTimestamp64>(const TUnboxedValuePod& value) { + return GetTzIntegerHash<i64>(value); +} + +template <> inline THashType GetValueHash<EDataSlot::Decimal>(const TUnboxedValuePod& value) { const auto pair = NYql::NDecimal::MakePair(value.GetInt128()); return CombineHashes(pair.first, pair.second); @@ -415,6 +430,21 @@ inline int CompareValues<EDataSlot::Interval64>(const TUnboxedValuePod& lhs, con } template <> +inline int CompareValues<EDataSlot::TzDate32>(const TUnboxedValuePod& lhs, const TUnboxedValuePod& rhs) { + return CompareTzIntegers<i32>(lhs, rhs); +} + +template <> +inline int CompareValues<EDataSlot::TzDatetime64>(const TUnboxedValuePod& lhs, const TUnboxedValuePod& rhs) { + return CompareTzIntegers<i64>(lhs, rhs); +} + +template <> +inline int CompareValues<EDataSlot::TzTimestamp64>(const TUnboxedValuePod& lhs, const TUnboxedValuePod& rhs) { + return CompareTzIntegers<i64>(lhs, rhs); +} + +template <> inline int CompareValues<EDataSlot::Decimal>(const TUnboxedValuePod& lhs, const TUnboxedValuePod& rhs) { const auto x = lhs.GetInt128(); const auto y = rhs.GetInt128(); @@ -605,6 +635,21 @@ inline bool EquateValues<EDataSlot::Interval64>(const TUnboxedValuePod& lhs, con } template <> +inline bool EquateValues<EDataSlot::TzDate32>(const TUnboxedValuePod& lhs, const TUnboxedValuePod& rhs) { + return EquateTzIntegers<i32>(lhs, rhs); +} + +template <> +inline bool EquateValues<EDataSlot::TzDatetime64>(const TUnboxedValuePod& lhs, const TUnboxedValuePod& rhs) { + return EquateTzIntegers<i64>(lhs, rhs); +} + +template <> +inline bool EquateValues<EDataSlot::TzTimestamp64>(const TUnboxedValuePod& lhs, const TUnboxedValuePod& rhs) { + return EquateTzIntegers<i64>(lhs, rhs); +} + +template <> inline bool EquateValues<EDataSlot::Decimal>(const TUnboxedValuePod& lhs, const TUnboxedValuePod& rhs) { return lhs.GetInt128() == rhs.GetInt128(); } |
