aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorvvvv <vvvv@ydb.tech>2023-10-12 17:35:10 +0300
committervvvv <vvvv@ydb.tech>2023-10-12 17:56:55 +0300
commitb163a3d343f6e5c37b528f2ea6ba5b5e08c433eb (patch)
tree3f84810ea8f45f8944fedb6afcf822e35dcf11ae
parente27b8a176337e927c312ba2c79e080bbb68b6734 (diff)
downloadydb-b163a3d343f6e5c37b528f2ea6ba5b5e08c433eb.tar.gz
YQL-16838 initial support of big dates
-rw-r--r--ydb/library/yql/core/type_ann/type_ann_core.cpp16
-rw-r--r--ydb/library/yql/dq/runtime/dq_arrow_helpers.cpp4
-rw-r--r--ydb/library/yql/dq/runtime/dq_transport.cpp4
-rw-r--r--ydb/library/yql/dq/type_ann/dq_type_ann.cpp4
-rw-r--r--ydb/library/yql/minikql/mkql_program_builder.cpp20
-rw-r--r--ydb/library/yql/minikql/mkql_type_ops.cpp40
-rw-r--r--ydb/library/yql/providers/common/codec/yql_codec.cpp16
-rw-r--r--ydb/library/yql/providers/common/mkql/yql_provider_mkql.cpp24
-rw-r--r--ydb/library/yql/providers/common/schema/skiff/yql_skiff_schema.cpp4
-rw-r--r--ydb/library/yql/providers/yt/lib/expr_traits/yql_expr_traits.cpp4
-rw-r--r--ydb/library/yql/public/types/yql_types.proto4
-rw-r--r--ydb/library/yql/public/udf/udf_data_type.h28
-rw-r--r--ydb/library/yql/public/udf/udf_type_ops.h60
-rw-r--r--ydb/library/yql/tests/sql/suites/bigdate/default.cfg0
-rw-r--r--ydb/library/yql/tests/sql/suites/bigdate/int_literals.sql14
15 files changed, 239 insertions, 3 deletions
diff --git a/ydb/library/yql/core/type_ann/type_ann_core.cpp b/ydb/library/yql/core/type_ann/type_ann_core.cpp
index 52527f04fcd..8d09694f07d 100644
--- a/ydb/library/yql/core/type_ann/type_ann_core.cpp
+++ b/ydb/library/yql/core/type_ann/type_ann_core.cpp
@@ -731,6 +731,22 @@ namespace NTypeAnnImpl {
return IGraphTransformer::TStatus::Error;
}
+ } else if (input->Content() == "Date32") {
+ if (!IsValidSmallData<i32>(input->Head(), input->Content(), ctx.Expr, NKikimr::NUdf::EDataSlot::Date32, textValue)) {
+ return IGraphTransformer::TStatus::Error;
+ }
+ } else if (input->Content() == "Datetime64") {
+ if (!IsValidSmallData<i64>(input->Head(), input->Content(), ctx.Expr, NKikimr::NUdf::EDataSlot::Datetime64, textValue)) {
+ return IGraphTransformer::TStatus::Error;
+ }
+ } else if (input->Content() == "Timestamp64") {
+ if (!IsValidSmallData<i64>(input->Head(), input->Content(), ctx.Expr, NKikimr::NUdf::EDataSlot::Timestamp64, textValue)) {
+ return IGraphTransformer::TStatus::Error;
+ }
+ } else if (input->Content() == "Interval64") {
+ if (!IsValidSmallData<i64>(input->Head(), input->Content(), ctx.Expr, NKikimr::NUdf::EDataSlot::Interval64, textValue)) {
+ return IGraphTransformer::TStatus::Error;
+ }
} else {
ythrow yexception() << "Unknown data type: " << input->Content();
}
diff --git a/ydb/library/yql/dq/runtime/dq_arrow_helpers.cpp b/ydb/library/yql/dq/runtime/dq_arrow_helpers.cpp
index 738aa6a26b3..83fafb33faa 100644
--- a/ydb/library/yql/dq/runtime/dq_arrow_helpers.cpp
+++ b/ydb/library/yql/dq/runtime/dq_arrow_helpers.cpp
@@ -61,11 +61,15 @@ bool SwitchMiniKQLDataTypeToArrowType(NUdf::EDataSlot type, TFunc&& callback) {
case NUdf::EDataSlot::Uint16:
return callback(TTypeWrapper<arrow::UInt16Type>());
case NUdf::EDataSlot::Int32:
+ case NUdf::EDataSlot::Date32:
return callback(TTypeWrapper<arrow::Int32Type>());
case NUdf::EDataSlot::Datetime:
case NUdf::EDataSlot::Uint32:
return callback(TTypeWrapper<arrow::UInt32Type>());
case NUdf::EDataSlot::Int64:
+ case NUdf::EDataSlot::Datetime64:
+ case NUdf::EDataSlot::Timestamp64:
+ case NUdf::EDataSlot::Interval64:
return callback(TTypeWrapper<arrow::Int64Type>());
case NUdf::EDataSlot::Uint64:
return callback(TTypeWrapper<arrow::UInt64Type>());
diff --git a/ydb/library/yql/dq/runtime/dq_transport.cpp b/ydb/library/yql/dq/runtime/dq_transport.cpp
index e3c1998746d..92237e5e7c5 100644
--- a/ydb/library/yql/dq/runtime/dq_transport.cpp
+++ b/ydb/library/yql/dq/runtime/dq_transport.cpp
@@ -199,6 +199,7 @@ std::optional<ui64> EstimateIntegralDataSize(const TDataType* dataType) {
case NUdf::EDataSlot::TzDate:
case NUdf::EDataSlot::Datetime:
case NUdf::EDataSlot::TzDatetime:
+ case NUdf::EDataSlot::Date32:
return 4;
case NUdf::EDataSlot::Int64:
case NUdf::EDataSlot::Uint64:
@@ -206,6 +207,9 @@ std::optional<ui64> EstimateIntegralDataSize(const TDataType* dataType) {
case NUdf::EDataSlot::Timestamp:
case NUdf::EDataSlot::TzTimestamp:
case NUdf::EDataSlot::Interval:
+ case NUdf::EDataSlot::Datetime64:
+ case NUdf::EDataSlot::Timestamp64:
+ case NUdf::EDataSlot::Interval64:
return 8;
case NUdf::EDataSlot::Uuid:
case NUdf::EDataSlot::Decimal:
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 b5160a301e1..4cc5d09056d 100644
--- a/ydb/library/yql/dq/type_ann/dq_type_ann.cpp
+++ b/ydb/library/yql/dq/type_ann/dq_type_ann.cpp
@@ -1116,6 +1116,10 @@ bool IsTypeSupportedInMergeCn(EDataSlot type) {
case EDataSlot::TzDatetime:
case EDataSlot::TzTimestamp:
case EDataSlot::JsonDocument:
+ case EDataSlot::Date32:
+ case EDataSlot::Datetime64:
+ case EDataSlot::Timestamp64:
+ case EDataSlot::Interval64:
return false;
}
return false;
diff --git a/ydb/library/yql/minikql/mkql_program_builder.cpp b/ydb/library/yql/minikql/mkql_program_builder.cpp
index b96746a03ce..25ed7fc97ec 100644
--- a/ydb/library/yql/minikql/mkql_program_builder.cpp
+++ b/ydb/library/yql/minikql/mkql_program_builder.cpp
@@ -2277,6 +2277,26 @@ TRuntimeNode TProgramBuilder::NewDecimalLiteral(NYql::NDecimal::TInt128 data, ui
return TRuntimeNode(TDataLiteral::Create(NUdf::TUnboxedValuePod(data), TDataDecimalType::Create(precision, scale, Env), Env), true);
}
+template<>
+TRuntimeNode TProgramBuilder::NewDataLiteral<NUdf::EDataSlot::Date32>(const NUdf::TStringRef& data) const {
+ return TRuntimeNode(BuildDataLiteral(data, NUdf::TDataType<NUdf::TDate32>::Id, Env), true);
+}
+
+template<>
+TRuntimeNode TProgramBuilder::NewDataLiteral<NUdf::EDataSlot::Datetime64>(const NUdf::TStringRef& data) const {
+ return TRuntimeNode(BuildDataLiteral(data, NUdf::TDataType<NUdf::TDatetime64>::Id, Env), true);
+}
+
+template<>
+TRuntimeNode TProgramBuilder::NewDataLiteral<NUdf::EDataSlot::Timestamp64>(const NUdf::TStringRef& data) const {
+ return TRuntimeNode(BuildDataLiteral(data, NUdf::TDataType<NUdf::TTimestamp64>::Id, Env), true);
+}
+
+template<>
+TRuntimeNode TProgramBuilder::NewDataLiteral<NUdf::EDataSlot::Interval64>(const NUdf::TStringRef& data) const {
+ return TRuntimeNode(BuildDataLiteral(data, NUdf::TDataType<NUdf::TInterval64>::Id, Env), true);
+}
+
TRuntimeNode TProgramBuilder::NewOptional(TRuntimeNode data) {
auto type = TOptionalType::Create(data.GetStaticType(), Env);
return TRuntimeNode(TOptionalLiteral::Create(data, type, Env), true);
diff --git a/ydb/library/yql/minikql/mkql_type_ops.cpp b/ydb/library/yql/minikql/mkql_type_ops.cpp
index d890625222e..e563b25b655 100644
--- a/ydb/library/yql/minikql/mkql_type_ops.cpp
+++ b/ydb/library/yql/minikql/mkql_type_ops.cpp
@@ -123,6 +123,18 @@ bool IsValidValue(NUdf::EDataSlot type, const NUdf::TUnboxedValuePod& value) {
case NUdf::EDataSlot::Interval:
return bool(value) && (ui64)std::abs(value.Get<i64>()) < NUdf::MAX_TIMESTAMP;
+ case NUdf::EDataSlot::Date32:
+ return bool(value) && value.Get<i32>() >= NUdf::MIN_DATE32 && value.Get<i32>() <= NUdf::MAX_DATE32;
+
+ case NUdf::EDataSlot::Datetime64:
+ return bool(value) && value.Get<i64>() >= NUdf::MIN_DATETIME64 && value.Get<i64>() <= NUdf::MAX_DATETIME64;
+
+ case NUdf::EDataSlot::Timestamp64:
+ return bool(value) && value.Get<i64>() >= NUdf::MIN_TIMESTAMP64 && value.Get<i64>() <= NUdf::MAX_TIMESTAMP64;
+
+ case NUdf::EDataSlot::Interval64:
+ return bool(value) && (ui64)std::abs(value.Get<i64>()) <= NUdf::MAX_INTERVAL64;
+
case NUdf::EDataSlot::TzDate:
return bool(value) && value.Get<ui16>() < NUdf::MAX_DATE && value.GetTimezoneId() < NUdf::GetTimezones().size();
@@ -1571,6 +1583,10 @@ bool IsValidStringValue(NUdf::EDataSlot type, NUdf::TStringRef buf) {
case NUdf::EDataSlot::TzDate:
case NUdf::EDataSlot::TzDatetime:
case NUdf::EDataSlot::TzTimestamp:
+ case NUdf::EDataSlot::Date32:
+ case NUdf::EDataSlot::Datetime64:
+ case NUdf::EDataSlot::Timestamp64:
+ case NUdf::EDataSlot::Interval64:
return bool(ValueFromString(type, buf));
default:
@@ -1688,6 +1704,22 @@ NUdf::TUnboxedValuePod ValueFromString(NUdf::EDataSlot type, NUdf::TStringRef bu
return MakeString(TStringBuf(binaryJson->Data(), binaryJson->Size()));
}
+ case NUdf::EDataSlot::Date32:
+ //TODO
+ return {};
+
+ case NUdf::EDataSlot::Datetime64:
+ //TODO
+ return {};
+
+ case NUdf::EDataSlot::Timestamp64:
+ //TODO
+ return {};
+
+ case NUdf::EDataSlot::Interval64:
+ //TODO
+ return {};
+
case NUdf::EDataSlot::Decimal:
default:
break;
@@ -1762,6 +1794,10 @@ NUdf::TUnboxedValuePod SimpleValueFromYson(NUdf::EDataSlot type, NUdf::TStringRe
case NUdf::EDataSlot::TzTimestamp:
case NUdf::EDataSlot::Decimal:
case NUdf::EDataSlot::Uuid:
+ case NUdf::EDataSlot::Date32:
+ case NUdf::EDataSlot::Datetime64:
+ case NUdf::EDataSlot::Timestamp64:
+ case NUdf::EDataSlot::Interval64:
Y_FAIL("TODO");
default:
@@ -1873,6 +1909,10 @@ NUdf::TUnboxedValuePod SimpleValueFromYson(NUdf::EDataSlot type, NUdf::TStringRe
case NUdf::EDataSlot::Uuid:
case NUdf::EDataSlot::DyNumber:
case NUdf::EDataSlot::JsonDocument:
+ case NUdf::EDataSlot::Date32:
+ case NUdf::EDataSlot::Datetime64:
+ case NUdf::EDataSlot::Timestamp64:
+ case NUdf::EDataSlot::Interval64:
Y_FAIL("TODO");
}
diff --git a/ydb/library/yql/providers/common/codec/yql_codec.cpp b/ydb/library/yql/providers/common/codec/yql_codec.cpp
index 49ffc368236..8d13e353c88 100644
--- a/ydb/library/yql/providers/common/codec/yql_codec.cpp
+++ b/ydb/library/yql/providers/common/codec/yql_codec.cpp
@@ -127,6 +127,18 @@ void WriteYsonValueImpl(TYsonResultWriter& writer, const NUdf::TUnboxedValuePod&
writer.OnUtf8StringScalar(out.AsStringRef());
return;
}
+ case NUdf::TDataType<NUdf::TDate32>::Id:
+ writer.OnInt64Scalar(value.Get<i32>());
+ return;
+ case NUdf::TDataType<NUdf::TDatetime64>::Id:
+ writer.OnInt64Scalar(value.Get<i64>());
+ return;
+ case NUdf::TDataType<NUdf::TTimestamp64>::Id:
+ writer.OnInt64Scalar(value.Get<i64>());
+ return;
+ case NUdf::TDataType<NUdf::TInterval64>::Id:
+ writer.OnInt64Scalar(value.Get<i64>());
+ return;
default:
throw yexception() << "Unknown data type: " << dataType->GetSchemeType();
@@ -415,9 +427,13 @@ TExprNode::TPtr DataNodeToExprLiteral(TPositionHandle pos, const TTypeAnnotation
TString DataValueToString(const NKikimr::NUdf::TUnboxedValuePod& value, const TDataExprType* type) {
switch (type->GetSlot()) {
case NUdf::EDataSlot::Int32:
+ case NUdf::EDataSlot::Date32:
return ToString(value.Get<i32>());
case NUdf::EDataSlot::Int64:
case NUdf::EDataSlot::Interval:
+ case NUdf::EDataSlot::Datetime64:
+ case NUdf::EDataSlot::Timestamp64:
+ case NUdf::EDataSlot::Interval64:
return ToString(value.Get<i64>());
case NUdf::EDataSlot::Uint32:
case NUdf::EDataSlot::Datetime:
diff --git a/ydb/library/yql/providers/common/mkql/yql_provider_mkql.cpp b/ydb/library/yql/providers/common/mkql/yql_provider_mkql.cpp
index 9c0e32757a0..ab7e369f24c 100644
--- a/ydb/library/yql/providers/common/mkql/yql_provider_mkql.cpp
+++ b/ydb/library/yql/providers/common/mkql/yql_provider_mkql.cpp
@@ -1130,6 +1130,30 @@ TMkqlCommonCallableCompiler::TShared::TShared() {
return ctx.ProgramBuilder.NewTzDataLiteral<NUdf::TTzTimestamp>(parts.first, parts.second);
});
+ AddCallable("Date32", [](const TExprNode& node, TMkqlBuildContext& ctx) {
+ const auto value = FromString<i32>(node.Head(), NUdf::EDataSlot::Date32);
+ return ctx.ProgramBuilder.NewDataLiteral<NUdf::EDataSlot::Date32>(
+ NUdf::TStringRef((const char*)&value, sizeof(value)));
+ });
+
+ AddCallable("Datetime64", [](const TExprNode& node, TMkqlBuildContext& ctx) {
+ const auto value = FromString<i64>(node.Head(), NUdf::EDataSlot::Datetime64);
+ return ctx.ProgramBuilder.NewDataLiteral<NUdf::EDataSlot::Datetime64>(
+ NUdf::TStringRef((const char*)&value, sizeof(value)));
+ });
+
+ AddCallable("Timestamp64", [](const TExprNode& node, TMkqlBuildContext& ctx) {
+ const auto value = FromString<i64>(node.Head(), NUdf::EDataSlot::Timestamp64);
+ return ctx.ProgramBuilder.NewDataLiteral<NUdf::EDataSlot::Timestamp64>(
+ NUdf::TStringRef((const char*)&value, sizeof(value)));
+ });
+
+ AddCallable("Interval64", [](const TExprNode& node, TMkqlBuildContext& ctx) {
+ const auto value = FromString<i64>(node.Head(), NUdf::EDataSlot::Interval64);
+ return ctx.ProgramBuilder.NewDataLiteral<NUdf::EDataSlot::Interval64>(
+ NUdf::TStringRef((const char*)&value, sizeof(value)));
+ });
+
AddCallable("FoldMap", [](const TExprNode& node, TMkqlBuildContext& ctx) {
const auto list = MkqlBuildExpr(node.Head(), ctx);
const auto state = MkqlBuildExpr(*node.Child(1), ctx);
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 20bcba1c8e9..467ec4d2013 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
@@ -51,6 +51,10 @@ struct TSkiffTypeLoader {
case NUdf::EDataSlot::Int32:
case NUdf::EDataSlot::Int64:
case NUdf::EDataSlot::Interval:
+ case NUdf::EDataSlot::Date32:
+ case NUdf::EDataSlot::Datetime64:
+ case NUdf::EDataSlot::Timestamp64:
+ case NUdf::EDataSlot::Interval64:
return NYT::TNode()("wire_type", "int64");
case NUdf::EDataSlot::Uint8:
case NUdf::EDataSlot::Uint16:
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 a4d86a5230e..300bd35a1be 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
@@ -222,6 +222,10 @@ namespace NYql {
case EDataSlot::Datetime:
case EDataSlot::Timestamp:
case EDataSlot::Interval:
+ case EDataSlot::Date32:
+ case EDataSlot::Datetime64:
+ case EDataSlot::Timestamp64:
+ case EDataSlot::Interval64:
return true;
case EDataSlot::String:
case EDataSlot::Utf8:
diff --git a/ydb/library/yql/public/types/yql_types.proto b/ydb/library/yql/public/types/yql_types.proto
index f9ebaf1390b..a14b347f184 100644
--- a/ydb/library/yql/public/types/yql_types.proto
+++ b/ydb/library/yql/public/types/yql_types.proto
@@ -28,6 +28,10 @@ enum TypeIds {
TzDate = 0x0034;
TzDatetime = 0x0035;
TzTimestamp = 0x0036;
+ Date32 = 0x0040;
+ Datetime64 = 0x0041;
+ Timestamp64 = 0x0042;
+ Interval64 = 0x0043;
Decimal = 0x1301;
DyNumber = 0x1302;
}
diff --git a/ydb/library/yql/public/udf/udf_data_type.h b/ydb/library/yql/public/udf/udf_data_type.h
index 29558c18793..3ffae34cb50 100644
--- a/ydb/library/yql/public/udf/udf_data_type.h
+++ b/ydb/library/yql/public/udf/udf_data_type.h
@@ -109,7 +109,11 @@ struct TTzDataType
xx(NUdf::TDate, ui16) \
xx(NUdf::TDatetime, ui32) \
xx(NUdf::TTimestamp, ui64) \
- xx(NUdf::TInterval, i64)
+ xx(NUdf::TInterval, i64) \
+ xx(NUdf::TDate32, i32) \
+ xx(NUdf::TDatetime64, i64) \
+ xx(NUdf::TTimestamp64, i64) \
+ xx(NUdf::TInterval64, i64)
template <typename T>
struct TPrimitiveDataType
@@ -140,14 +144,28 @@ class TInterval {};
class TTzDate {};
class TTzDatetime {};
class TTzTimestamp {};
+class TDate32 {};
+class TDatetime64 {};
+class TTimestamp64 {};
+class TInterval64 {};
class TDecimal {};
class TDyNumber {};
-constexpr ui16 MAX_DATE = 49673u;
+constexpr ui16 MAX_DATE = 49673u; // non-inclusive
constexpr ui32 MAX_DATETIME = 86400u * 49673u;
constexpr ui64 MAX_TIMESTAMP = 86400000000ull * 49673u;
constexpr ui32 MIN_YEAR = 1970u;
-constexpr ui32 MAX_YEAR = 2106u;
+constexpr ui32 MAX_YEAR = 2106u; // non-inclusive
+
+constexpr i32 MIN_DATE32 = -53375809; // inclusive
+constexpr i64 MIN_DATETIME64 = -4611669897600ll;
+constexpr i64 MIN_TIMESTAMP64 = -4611669897600000000ll;
+constexpr i32 MAX_DATE32 = 53375807; // inclusive
+constexpr i64 MAX_DATETIME64 = 4611669811199ll;
+constexpr i64 MAX_TIMESTAMP64 = 4611669811199999999ll;
+constexpr i64 MAX_INTERVAL64 = MAX_TIMESTAMP64 - MIN_TIMESTAMP64;
+constexpr i32 MIN_YEAR32 = -144169; // inclusive
+constexpr i32 MAX_YEAR32 = 148108; // non-inclusive
#define UDF_TYPE_ID_MAP(XX) \
XX(Bool, NYql::NProto::Bool, bool, CommonType, bool, 0) \
@@ -176,6 +194,10 @@ constexpr ui32 MAX_YEAR = 2106u;
XX(Decimal, NYql::NProto::Decimal, TDecimal, CommonType | DecimalType, TDecimal, 2) \
XX(DyNumber, NYql::NProto::DyNumber, TDyNumber, CommonType, TDyNumber, 0) \
XX(JsonDocument, NYql::NProto::JsonDocument, TJsonDocument, PayloadType, TJsonDocument, 0) \
+ XX(Date32, NYql::NProto::Date32, TDate32, CommonType | DateType, i32, 0) \
+ XX(Datetime64, NYql::NProto::Datetime64, TDatetime64, CommonType | DateType, i64, 0) \
+ XX(Timestamp64, NYql::NProto::Timestamp64, TTimestamp64, CommonType | DateType, i64, 0) \
+ XX(Interval64, NYql::NProto::Interval64, TInterval64, CommonType | TimeIntervalType, 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 21b79fffa32..60875dd4efc 100644
--- a/ydb/library/yql/public/udf/udf_type_ops.h
+++ b/ydb/library/yql/public/udf/udf_type_ops.h
@@ -184,6 +184,26 @@ inline THashType GetValueHash<EDataSlot::TzTimestamp>(const TUnboxedValuePod& va
}
template <>
+inline THashType GetValueHash<EDataSlot::Date32>(const TUnboxedValuePod& value) {
+ return GetIntegerHash<i32>(value);
+}
+
+template <>
+inline THashType GetValueHash<EDataSlot::Datetime64>(const TUnboxedValuePod& value) {
+ return GetIntegerHash<i64>(value);
+}
+
+template <>
+inline THashType GetValueHash<EDataSlot::Timestamp64>(const TUnboxedValuePod& value) {
+ return GetIntegerHash<i64>(value);
+}
+
+template <>
+inline THashType GetValueHash<EDataSlot::Interval64>(const TUnboxedValuePod& value) {
+ return GetIntegerHash<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);
@@ -375,6 +395,26 @@ inline int CompareValues<EDataSlot::TzTimestamp>(const TUnboxedValuePod& lhs, co
}
template <>
+inline int CompareValues<EDataSlot::Date32>(const TUnboxedValuePod& lhs, const TUnboxedValuePod& rhs) {
+ return CompareIntegers<i32>(lhs, rhs);
+}
+
+template <>
+inline int CompareValues<EDataSlot::Datetime64>(const TUnboxedValuePod& lhs, const TUnboxedValuePod& rhs) {
+ return CompareIntegers<i64>(lhs, rhs);
+}
+
+template <>
+inline int CompareValues<EDataSlot::Timestamp64>(const TUnboxedValuePod& lhs, const TUnboxedValuePod& rhs) {
+ return CompareIntegers<i64>(lhs, rhs);
+}
+
+template <>
+inline int CompareValues<EDataSlot::Interval64>(const TUnboxedValuePod& lhs, const TUnboxedValuePod& rhs) {
+ return CompareIntegers<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();
@@ -545,6 +585,26 @@ inline bool EquateValues<EDataSlot::TzTimestamp>(const TUnboxedValuePod& lhs, co
}
template <>
+inline bool EquateValues<EDataSlot::Date32>(const TUnboxedValuePod& lhs, const TUnboxedValuePod& rhs) {
+ return EquateIntegers<i32>(lhs, rhs);
+}
+
+template <>
+inline bool EquateValues<EDataSlot::Datetime64>(const TUnboxedValuePod& lhs, const TUnboxedValuePod& rhs) {
+ return EquateIntegers<i64>(lhs, rhs);
+}
+
+template <>
+inline bool EquateValues<EDataSlot::Timestamp64>(const TUnboxedValuePod& lhs, const TUnboxedValuePod& rhs) {
+ return EquateIntegers<i64>(lhs, rhs);
+}
+
+template <>
+inline bool EquateValues<EDataSlot::Interval64>(const TUnboxedValuePod& lhs, const TUnboxedValuePod& rhs) {
+ return EquateIntegers<i64>(lhs, rhs);
+}
+
+template <>
inline bool EquateValues<EDataSlot::Decimal>(const TUnboxedValuePod& lhs, const TUnboxedValuePod& rhs) {
return lhs.GetInt128() == rhs.GetInt128();
}
diff --git a/ydb/library/yql/tests/sql/suites/bigdate/default.cfg b/ydb/library/yql/tests/sql/suites/bigdate/default.cfg
new file mode 100644
index 00000000000..e69de29bb2d
--- /dev/null
+++ b/ydb/library/yql/tests/sql/suites/bigdate/default.cfg
diff --git a/ydb/library/yql/tests/sql/suites/bigdate/int_literals.sql b/ydb/library/yql/tests/sql/suites/bigdate/int_literals.sql
new file mode 100644
index 00000000000..cd897479873
--- /dev/null
+++ b/ydb/library/yql/tests/sql/suites/bigdate/int_literals.sql
@@ -0,0 +1,14 @@
+pragma warning("disable","4510");
+select
+ Yql::Date32(AsAtom("0")),
+ Yql::Datetime64(AsAtom("0")),
+ Yql::Timestamp64(AsAtom("0")),
+ Yql::Interval64(AsAtom("0")),
+ Yql::Date32(AsAtom("-53375809")),
+ Yql::Date32(AsAtom("53375807")),
+ Yql::Datetime64(AsAtom("-4611669897600")),
+ Yql::Datetime64(AsAtom("4611669811199")),
+ Yql::Timestamp64(AsAtom("-4611669897600000000")),
+ Yql::Timestamp64(AsAtom("4611669811199999999")),
+ Yql::Interval64(AsAtom("-9223339708799999999")),
+ Yql::Interval64(AsAtom("9223339708799999999"));