summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--yql/essentials/minikql/datetime/datetime.cpp28
-rw-r--r--yql/essentials/minikql/datetime/datetime.h35
-rw-r--r--yql/essentials/udfs/common/datetime2/datetime_udf.cpp148
-rw-r--r--yql/essentials/udfs/common/datetime2/test/canondata/test.test_Shift_/results.txt1151
-rw-r--r--yql/essentials/udfs/common/datetime2/test/cases/Shift.sql51
-rw-r--r--yql/essentials/udfs/common/datetime2/test_bigdates/canondata/result.json5
-rw-r--r--yql/essentials/udfs/common/datetime2/test_bigdates/canondata/test.test_Shift_/results.txt982
-rw-r--r--yql/essentials/udfs/common/datetime2/test_bigdates/cases/Shift.cfg1
-rw-r--r--yql/essentials/udfs/common/datetime2/test_bigdates/cases/Shift.in8
-rw-r--r--yql/essentials/udfs/common/datetime2/test_bigdates/cases/Shift.in.attr16
-rw-r--r--yql/essentials/udfs/common/datetime2/test_bigdates/cases/Shift.sql31
11 files changed, 2013 insertions, 443 deletions
diff --git a/yql/essentials/minikql/datetime/datetime.cpp b/yql/essentials/minikql/datetime/datetime.cpp
index 0b2819f6a9f..a1cb0c0f9c1 100644
--- a/yql/essentials/minikql/datetime/datetime.cpp
+++ b/yql/essentials/minikql/datetime/datetime.cpp
@@ -1,35 +1,7 @@
#include "datetime.h"
-#include <yql/essentials/minikql/mkql_type_ops.h>
-
namespace NYql::DateTime {
-bool DoAddMonths(TTMStorage& storage, i64 months, const NUdf::IDateBuilder& builder) {
- i64 newMonth = months + storage.Month;
- storage.Year += (newMonth - 1) / 12;
- newMonth = 1 + (newMonth - 1) % 12;
- if (newMonth <= 0) {
- storage.Year--;
- newMonth += 12;
- }
- storage.Month = newMonth;
- bool isLeap = NKikimr::NMiniKQL::IsLeapYear(storage.Year);
- ui32 monthLength = NKikimr::NMiniKQL::GetMonthLength(storage.Month, isLeap);
- storage.Day = std::min(monthLength, storage.Day);
- return storage.Validate(builder);
-}
-
-bool DoAddYears(TTMStorage& storage, i64 years, const NUdf::IDateBuilder& builder) {
- storage.Year += years;
- if (storage.Month == 2 && storage.Day == 29) {
- bool isLeap = NKikimr::NMiniKQL::IsLeapYear(storage.Year);
- if (!isLeap) {
- storage.Day--;
- }
- }
- return storage.Validate(builder);
-}
-
TInstant DoAddMonths(TInstant current, i64 months, const NUdf::IDateBuilder& builder) {
TTMStorage storage;
storage.FromTimestamp(builder, current.GetValue());
diff --git a/yql/essentials/minikql/datetime/datetime.h b/yql/essentials/minikql/datetime/datetime.h
index 2c2668064a3..d9569b5904b 100644
--- a/yql/essentials/minikql/datetime/datetime.h
+++ b/yql/essentials/minikql/datetime/datetime.h
@@ -2,6 +2,7 @@
#include <yql/essentials/public/udf/udf_value_builder.h>
#include <yql/essentials/public/udf/tz/udf_tz.h>
+#include <yql/essentials/minikql/mkql_type_ops.h>
#include <util/datetime/base.h>
#include <util/string/printf.h>
@@ -159,9 +160,39 @@ struct TTMStorage {
static_assert(sizeof(TTMStorage) == 16, "TTMStorage size must be equal to TUnboxedValuePod size");
-bool DoAddMonths(TTMStorage& storage, i64 months, const NUdf::IDateBuilder& builder);
+template<typename TStorage>
+bool DoAddMonths(TStorage& storage, i64 months, const NUdf::IDateBuilder& builder) {
+ i64 newMonth = months + storage.Month;
+ storage.Year += (newMonth - 1) / 12;
+ newMonth = 1 + (newMonth - 1) % 12;
+ if (newMonth <= 0) {
+ storage.Year--;
+ newMonth += 12;
+ }
+ if (storage.Year == 0) {
+ storage.Year += months > 0 ? 1 : -1;
+ }
+ storage.Month = newMonth;
+ bool isLeap = NKikimr::NMiniKQL::IsLeapYear(storage.Year);
+ ui32 monthLength = NKikimr::NMiniKQL::GetMonthLength(storage.Month, isLeap);
+ storage.Day = std::min(monthLength, storage.Day);
+ return storage.Validate(builder);
+}
-bool DoAddYears(TTMStorage& storage, i64 years, const NUdf::IDateBuilder& builder);
+template<typename TStorage>
+bool DoAddYears(TStorage& storage, i64 years, const NUdf::IDateBuilder& builder) {
+ storage.Year += years;
+ if (storage.Year == 0) {
+ storage.Year += years > 0 ? 1 : -1;
+ }
+ if (storage.Month == 2 && storage.Day == 29) {
+ bool isLeap = NKikimr::NMiniKQL::IsLeapYear(storage.Year);
+ if (!isLeap) {
+ storage.Day--;
+ }
+ }
+ return storage.Validate(builder);
+}
TInstant DoAddMonths(TInstant current, i64 months, const NUdf::IDateBuilder& builder);
diff --git a/yql/essentials/udfs/common/datetime2/datetime_udf.cpp b/yql/essentials/udfs/common/datetime2/datetime_udf.cpp
index 30c1a46ef25..edc65c12a20 100644
--- a/yql/essentials/udfs/common/datetime2/datetime_udf.cpp
+++ b/yql/essentials/udfs/common/datetime2/datetime_udf.cpp
@@ -42,6 +42,9 @@ extern const char EndOfQuarterUDF[] = "EndOfQuarter";
extern const char EndOfMonthUDF[] = "EndOfMonth";
extern const char EndOfWeekUDF[] = "EndOfWeek";
extern const char EndOfDayUDF[] = "EndOfDay";
+extern const char ShiftYearsUDF[] = "ShiftYears";
+extern const char ShiftQuartersUDF[] = "ShiftQuarters";
+extern const char ShiftMonthsUDF[] = "ShiftMonths";
extern const char TMResourceName[] = "DateTime2.TM";
extern const char TM64ResourceName[] = "DateTime2.TM64";
@@ -451,27 +454,27 @@ TStorage& Reference(TValue& value) {
return *reinterpret_cast<TStorage*>(value.GetRawPtr());
}
-template<typename TValue>
-TValue DoAddMonths(const TValue& date, i64 months, const NUdf::IDateBuilder& builder) {
+template<const char* TResourceName>
+TUnboxedValuePod DoAddMonths(const TUnboxedValuePod& date, i64 months, const NUdf::IDateBuilder& builder) {
auto result = date;
- auto& storage = Reference(result);
+ auto& storage = Reference<TResourceName>(result);
if (!NYql::DateTime::DoAddMonths(storage, months, builder)) {
- return TValue{};
+ return TUnboxedValuePod{};
}
return result;
}
-template<typename TValue>
-TValue DoAddQuarters(const TValue& date, i64 quarters, const NUdf::IDateBuilder& builder) {
- return DoAddMonths(date, quarters * 3ll, builder);
+template<const char* TResourceName>
+TUnboxedValuePod DoAddQuarters(const TUnboxedValuePod& date, i64 quarters, const NUdf::IDateBuilder& builder) {
+ return DoAddMonths<TResourceName>(date, quarters * 3ll, builder);
}
-template<typename TValue>
-TValue DoAddYears(const TValue& date, i64 years, const NUdf::IDateBuilder& builder) {
+template<const char* TResourceName>
+TUnboxedValuePod DoAddYears(const TUnboxedValuePod& date, i64 years, const NUdf::IDateBuilder& builder) {
auto result = date;
- auto& storage = Reference(result);
+ auto& storage = Reference<TResourceName>(result);
if (!NYql::DateTime::DoAddYears(storage, years, builder)) {
- return TValue{};
+ return TUnboxedValuePod{};
}
return result;
}
@@ -2088,20 +2091,119 @@ private:
}
};
- BEGIN_SIMPLE_STRICT_ARROW_UDF(TShiftYears, TOptional<TResource<TMResourceName>>(TAutoMap<TResource<TMResourceName>>, i32)) {
- return DoAddYears(args[0], args[1].Get<i32>(), valueBuilder->GetDateBuilder());
+template<const char* TUdfName, auto Shifter, auto WShifter>
+class TShift : public TBoxedValue {
+public:
+ typedef bool TTypeAwareMarker;
+
+ static const TStringRef& Name() {
+ static auto name = TStringRef(TUdfName, std::strlen(TUdfName));
+ return name;
+ }
+
+ static bool DeclareSignature(
+ const TStringRef& name,
+ TType* userType,
+ IFunctionTypeInfoBuilder& builder,
+ bool typesOnly)
+ {
+ if (Name() != name) {
+ return false;
+ }
+
+ if (!userType) {
+ builder.SetError("User type is missing");
+ return true;
+ }
+
+ builder.UserType(userType);
+
+ const auto typeInfoHelper = builder.TypeInfoHelper();
+ TTupleTypeInspector tuple(*typeInfoHelper, userType);
+ Y_ENSURE(tuple, "Tuple with args and options tuples expected");
+ Y_ENSURE(tuple.GetElementsCount() > 0,
+ "Tuple has to contain positional arguments");
+
+ TTupleTypeInspector argsTuple(*typeInfoHelper, tuple.GetElementType(0));
+ Y_ENSURE(argsTuple, "Tuple with args expected");
+ if (argsTuple.GetElementsCount() != 2) {
+ builder.SetError("Only two arguments expected");
+ return true;
+ }
+
+ auto argType = argsTuple.GetElementType(0);
+
+ if (const auto optType = TOptionalTypeInspector(*typeInfoHelper, argType)) {
+ argType = optType.GetItemType();
+ }
+
+ TResourceTypeInspector resource(*typeInfoHelper, argType);
+ if (!resource) {
+ TDataTypeInspector data(*typeInfoHelper, argType);
+ if (!data) {
+ SetInvalidTypeError(builder, typeInfoHelper, argType);
+ return true;
+ }
+
+ const auto features = NUdf::GetDataTypeInfo(NUdf::GetDataSlot(data.GetTypeId())).Features;
+ if (features & NUdf::BigDateType) {
+ BuildSignature<TM64ResourceName, WShifter>(builder, typesOnly);
+ return true;
+ }
+ if (features & (NUdf::DateType | NUdf::TzDateType)) {
+ BuildSignature<TMResourceName, Shifter>(builder, typesOnly);
+ return true;
+ }
+
+ SetInvalidTypeError(builder, typeInfoHelper, argType);
+ return true;
+ }
+
+ if (resource.GetTag() == TStringRef::Of(TM64ResourceName)) {
+ BuildSignature<TM64ResourceName, WShifter>(builder, typesOnly);
+ return true;
+ }
+
+ if (resource.GetTag() == TStringRef::Of(TMResourceName)) {
+ BuildSignature<TMResourceName, Shifter>(builder, typesOnly);
+ return true;
+ }
+
+ ::TStringBuilder sb;
+ sb << "Unexpected Resource tag: got '" << resource.GetTag() << "'";
+ builder.SetError(sb);
+ return true;
}
- END_SIMPLE_ARROW_UDF(TShiftYears, TAddKernelExec<DoAddYears<TBlockItem>>::Do);
+private:
+ template<auto ShiftHanler>
+ class TImpl : public TBoxedValue {
+ public:
+ TUnboxedValue Run(const IValueBuilder* valueBuilder, const TUnboxedValuePod* args) const final {
+ return ShiftHanler(args[0], args[1].Get<i32>(), valueBuilder->GetDateBuilder());
+ }
+ };
- BEGIN_SIMPLE_STRICT_ARROW_UDF(TShiftQuarters, TOptional<TResource<TMResourceName>>(TAutoMap<TResource<TMResourceName>>, i32)) {
- return DoAddQuarters(args[0], args[1].Get<i32>(), valueBuilder->GetDateBuilder());
+ static void SetInvalidTypeError(NUdf::IFunctionTypeInfoBuilder& builder,
+ ITypeInfoHelper::TPtr typeInfoHelper, const TType* argType)
+ {
+ ::TStringBuilder sb;
+ sb << "Invalid argument type: got ";
+ TTypePrinter(*typeInfoHelper, argType).Out(sb.Out);
+ sb << ", but Resource<" << TMResourceName <<"> or Resource<"
+ << TM64ResourceName << "> expected";
+ builder.SetError(sb);
}
- END_SIMPLE_ARROW_UDF(TShiftQuarters, TAddKernelExec<DoAddQuarters<TBlockItem>>::Do);
- BEGIN_SIMPLE_STRICT_ARROW_UDF(TShiftMonths, TOptional<TResource<TMResourceName>>(TAutoMap<TResource<TMResourceName>>, i32)) {
- return DoAddMonths(args[0], args[1].Get<i32>(), valueBuilder->GetDateBuilder());
+ template<const char* TResourceName, auto ShiftHandler>
+ static void BuildSignature(NUdf::IFunctionTypeInfoBuilder& builder, bool typesOnly) {
+ builder.Returns<TOptional<TResource<TResourceName>>>();
+ builder.Args()->Add<TAutoMap<TResource<TResourceName>>>().template Add<i32>();
+ builder.IsStrict();
+ if (!typesOnly) {
+ builder.Implementation(new TImpl<ShiftHandler>());
+ }
}
- END_SIMPLE_ARROW_UDF(TShiftMonths, TAddKernelExec<DoAddMonths<TBlockItem>>::Do);
+};
template<size_t Digits, bool Exacly = true>
struct PrintNDigits;
@@ -2860,9 +2962,9 @@ private:
TStartOf,
TTimeOfDay,
- TShiftYears,
- TShiftQuarters,
- TShiftMonths,
+ TShift<ShiftYearsUDF, DoAddYears<TMResourceName>, DoAddYears<TM64ResourceName>>,
+ TShift<ShiftQuartersUDF, DoAddQuarters<TMResourceName>, DoAddQuarters<TM64ResourceName>>,
+ TShift<ShiftMonthsUDF, DoAddMonths<TMResourceName>, DoAddMonths<TM64ResourceName>>,
TBoundaryOf<EndOfYearUDF, SimpleDatetimeToDatetimeUdf<TMResourceName, EndOfYear<TTMStorage>>,
SimpleDatetimeToDatetimeUdf<TM64ResourceName, EndOfYear<TTM64Storage>>>,
diff --git a/yql/essentials/udfs/common/datetime2/test/canondata/test.test_Shift_/results.txt b/yql/essentials/udfs/common/datetime2/test/canondata/test.test_Shift_/results.txt
index a7d9edbd5a5..d00b8b120e3 100644
--- a/yql/essentials/udfs/common/datetime2/test/canondata/test.test_Shift_/results.txt
+++ b/yql/essentials/udfs/common/datetime2/test/canondata/test.test_Shift_/results.txt
@@ -8,449 +8,862 @@
"StructType";
[
[
- "column0";
+ "explicit";
[
- "OptionalType";
+ "StructType";
[
- "DataType";
- "String"
+ [
+ "sh0m";
+ [
+ "OptionalType";
+ [
+ "DataType";
+ "String"
+ ]
+ ]
+ ];
+ [
+ "sh10y";
+ [
+ "OptionalType";
+ [
+ "DataType";
+ "String"
+ ]
+ ]
+ ];
+ [
+ "sh11m";
+ [
+ "OptionalType";
+ [
+ "DataType";
+ "String"
+ ]
+ ]
+ ];
+ [
+ "sh123m";
+ [
+ "OptionalType";
+ [
+ "DataType";
+ "String"
+ ]
+ ]
+ ];
+ [
+ "sh12m";
+ [
+ "OptionalType";
+ [
+ "DataType";
+ "String"
+ ]
+ ]
+ ];
+ [
+ "sh16q";
+ [
+ "OptionalType";
+ [
+ "DataType";
+ "String"
+ ]
+ ]
+ ];
+ [
+ "sh1m";
+ [
+ "OptionalType";
+ [
+ "DataType";
+ "String"
+ ]
+ ]
+ ];
+ [
+ "sh3m";
+ [
+ "OptionalType";
+ [
+ "DataType";
+ "String"
+ ]
+ ]
+ ];
+ [
+ "shm11m";
+ [
+ "OptionalType";
+ [
+ "DataType";
+ "String"
+ ]
+ ]
+ ];
+ [
+ "shm123m";
+ [
+ "OptionalType";
+ [
+ "DataType";
+ "String"
+ ]
+ ]
+ ];
+ [
+ "shm12m";
+ [
+ "OptionalType";
+ [
+ "DataType";
+ "String"
+ ]
+ ]
+ ];
+ [
+ "shm16q";
+ [
+ "OptionalType";
+ [
+ "DataType";
+ "String"
+ ]
+ ]
+ ];
+ [
+ "shm1m";
+ [
+ "OptionalType";
+ [
+ "DataType";
+ "String"
+ ]
+ ]
+ ];
+ [
+ "shm3m";
+ [
+ "OptionalType";
+ [
+ "DataType";
+ "String"
+ ]
+ ]
+ ]
]
]
];
[
- "column1";
+ "implicit";
[
- "OptionalType";
+ "StructType";
[
- "DataType";
- "String"
+ [
+ "sh0m";
+ [
+ "OptionalType";
+ [
+ "DataType";
+ "String"
+ ]
+ ]
+ ];
+ [
+ "sh10y";
+ [
+ "OptionalType";
+ [
+ "DataType";
+ "String"
+ ]
+ ]
+ ];
+ [
+ "sh11m";
+ [
+ "OptionalType";
+ [
+ "DataType";
+ "String"
+ ]
+ ]
+ ];
+ [
+ "sh123m";
+ [
+ "OptionalType";
+ [
+ "DataType";
+ "String"
+ ]
+ ]
+ ];
+ [
+ "sh12m";
+ [
+ "OptionalType";
+ [
+ "DataType";
+ "String"
+ ]
+ ]
+ ];
+ [
+ "sh16q";
+ [
+ "OptionalType";
+ [
+ "DataType";
+ "String"
+ ]
+ ]
+ ];
+ [
+ "sh1m";
+ [
+ "OptionalType";
+ [
+ "DataType";
+ "String"
+ ]
+ ]
+ ];
+ [
+ "sh3m";
+ [
+ "OptionalType";
+ [
+ "DataType";
+ "String"
+ ]
+ ]
+ ];
+ [
+ "shm11m";
+ [
+ "OptionalType";
+ [
+ "DataType";
+ "String"
+ ]
+ ]
+ ];
+ [
+ "shm123m";
+ [
+ "OptionalType";
+ [
+ "DataType";
+ "String"
+ ]
+ ]
+ ];
+ [
+ "shm12m";
+ [
+ "OptionalType";
+ [
+ "DataType";
+ "String"
+ ]
+ ]
+ ];
+ [
+ "shm16q";
+ [
+ "OptionalType";
+ [
+ "DataType";
+ "String"
+ ]
+ ]
+ ];
+ [
+ "shm1m";
+ [
+ "OptionalType";
+ [
+ "DataType";
+ "String"
+ ]
+ ]
+ ];
+ [
+ "shm3m";
+ [
+ "OptionalType";
+ [
+ "DataType";
+ "String"
+ ]
+ ]
+ ]
]
]
+ ]
+ ]
+ ]
+ ];
+ "Data" = [
+ [
+ [
+ [
+ "2001-11-17T21:20:19.345678,GMT"
];
[
- "column2";
- [
- "OptionalType";
- [
- "DataType";
- "String"
- ]
- ]
+ "2011-11-17T21:20:19.345678,GMT"
];
[
- "column3";
- [
- "OptionalType";
- [
- "DataType";
- "String"
- ]
- ]
+ "2002-10-17T21:20:19.345678,GMT"
];
[
- "column4";
- [
- "OptionalType";
- [
- "DataType";
- "String"
- ]
- ]
+ "2012-02-17T21:20:19.345678,GMT"
];
[
- "column5";
- [
- "OptionalType";
- [
- "DataType";
- "String"
- ]
- ]
+ "2002-11-17T21:20:19.345678,GMT"
];
[
- "column6";
- [
- "OptionalType";
- [
- "DataType";
- "String"
- ]
- ]
+ "2005-11-17T21:20:19.345678,GMT"
];
[
- "column7";
- [
- "OptionalType";
- [
- "DataType";
- "String"
- ]
- ]
+ "2001-12-17T21:20:19.345678,GMT"
];
[
- "column8";
- [
- "OptionalType";
- [
- "DataType";
- "String"
- ]
- ]
+ "2002-02-17T21:20:19.345678,GMT"
];
[
- "column9";
- [
- "OptionalType";
- [
- "DataType";
- "String"
- ]
- ]
+ "2000-12-17T21:20:19.345678,GMT"
];
[
- "column10";
- [
- "OptionalType";
- [
- "DataType";
- "String"
- ]
- ]
+ "1991-08-17T21:20:19.345678,GMT"
];
[
- "column11";
- [
- "OptionalType";
- [
- "DataType";
- "String"
- ]
- ]
+ "2000-11-17T21:20:19.345678,GMT"
];
[
- "column12";
- [
- "OptionalType";
- [
- "DataType";
- "String"
- ]
- ]
+ "1997-11-17T21:20:19.345678,GMT"
];
[
- "column13";
- [
- "OptionalType";
- [
- "DataType";
- "String"
- ]
- ]
+ "2001-10-17T21:20:19.345678,GMT"
];
[
- "column14";
- [
- "OptionalType";
- [
- "DataType";
- "String"
- ]
- ]
+ "2001-08-17T21:20:19.345678,GMT"
]
- ]
- ]
- ];
- "Data" = [
- [
- [
- "2011-11-17T21:20:19.345678,GMT"
- ];
- [
- "2011-11-17T21:20:19.345678,GMT"
- ];
- [
- "2005-11-17T21:20:19.345678,GMT"
- ];
- [
- "1997-11-17T21:20:19.345678,GMT"
- ];
- [
- "2001-11-17T21:20:19.345678,GMT"
- ];
- [
- "2001-12-17T21:20:19.345678,GMT"
- ];
- [
- "2002-02-17T21:20:19.345678,GMT"
- ];
- [
- "2002-10-17T21:20:19.345678,GMT"
];
[
- "2002-11-17T21:20:19.345678,GMT"
- ];
- [
- "2012-02-17T21:20:19.345678,GMT"
- ];
- [
- "2001-10-17T21:20:19.345678,GMT"
- ];
- [
- "2001-08-17T21:20:19.345678,GMT"
- ];
- [
- "2000-12-17T21:20:19.345678,GMT"
- ];
- [
- "2000-11-17T21:20:19.345678,GMT"
- ];
- [
- "1991-08-17T21:20:19.345678,GMT"
+ [
+ "2001-11-17T21:20:19.345678,GMT"
+ ];
+ [
+ "2011-11-17T21:20:19.345678,GMT"
+ ];
+ [
+ "2002-10-17T21:20:19.345678,GMT"
+ ];
+ [
+ "2012-02-17T21:20:19.345678,GMT"
+ ];
+ [
+ "2002-11-17T21:20:19.345678,GMT"
+ ];
+ [
+ "2005-11-17T21:20:19.345678,GMT"
+ ];
+ [
+ "2001-12-17T21:20:19.345678,GMT"
+ ];
+ [
+ "2002-02-17T21:20:19.345678,GMT"
+ ];
+ [
+ "2000-12-17T21:20:19.345678,GMT"
+ ];
+ [
+ "1991-08-17T21:20:19.345678,GMT"
+ ];
+ [
+ "2000-11-17T21:20:19.345678,GMT"
+ ];
+ [
+ "1997-11-17T21:20:19.345678,GMT"
+ ];
+ [
+ "2001-10-17T21:20:19.345678,GMT"
+ ];
+ [
+ "2001-08-17T21:20:19.345678,GMT"
+ ]
]
];
[
[
- "1980-01-01T11:14:00,GMT"
- ];
- [
- "1980-01-01T11:14:00,GMT"
- ];
- [
- "1974-01-01T11:14:00,GMT"
- ];
- #;
- [
- "1970-01-01T11:14:00,GMT"
- ];
- [
- "1970-02-01T11:14:00,GMT"
- ];
- [
- "1970-04-01T11:14:00,GMT"
- ];
- [
- "1970-12-01T11:14:00,GMT"
- ];
- [
- "1971-01-01T11:14:00,GMT"
+ [
+ "1970-01-01T11:14:00,GMT"
+ ];
+ [
+ "1980-01-01T11:14:00,GMT"
+ ];
+ [
+ "1970-12-01T11:14:00,GMT"
+ ];
+ [
+ "1980-04-01T11:14:00,GMT"
+ ];
+ [
+ "1971-01-01T11:14:00,GMT"
+ ];
+ [
+ "1974-01-01T11:14:00,GMT"
+ ];
+ [
+ "1970-02-01T11:14:00,GMT"
+ ];
+ [
+ "1970-04-01T11:14:00,GMT"
+ ];
+ #;
+ #;
+ #;
+ #;
+ #;
+ #
];
[
- "1980-04-01T11:14:00,GMT"
- ];
- #;
- #;
- #;
- #;
- #
+ [
+ "1970-01-01T11:14:00,GMT"
+ ];
+ [
+ "1980-01-01T11:14:00,GMT"
+ ];
+ [
+ "1970-12-01T11:14:00,GMT"
+ ];
+ [
+ "1980-04-01T11:14:00,GMT"
+ ];
+ [
+ "1971-01-01T11:14:00,GMT"
+ ];
+ [
+ "1974-01-01T11:14:00,GMT"
+ ];
+ [
+ "1970-02-01T11:14:00,GMT"
+ ];
+ [
+ "1970-04-01T11:14:00,GMT"
+ ];
+ #;
+ #;
+ #;
+ #;
+ #;
+ #
+ ]
];
[
- #;
- #;
- #;
- [
- "2101-12-01T01:08:00,Europe/Moscow"
- ];
- [
- "2105-12-01T01:08:00,Europe/Moscow"
- ];
- [
- "2106-01-01T01:08:00,Europe/Moscow"
- ];
- #;
- #;
- #;
- #;
[
- "2105-11-01T01:08:00,Europe/Moscow"
- ];
- [
- "2105-09-01T01:08:00,Europe/Moscow"
- ];
- [
- "2105-01-01T01:08:00,Europe/Moscow"
- ];
- [
- "2104-12-01T01:08:00,Europe/Moscow"
+ [
+ "2105-12-01T01:08:00,Europe/Moscow"
+ ];
+ #;
+ #;
+ #;
+ #;
+ #;
+ [
+ "2106-01-01T01:08:00,Europe/Moscow"
+ ];
+ #;
+ [
+ "2105-01-01T01:08:00,Europe/Moscow"
+ ];
+ [
+ "2095-09-01T01:08:00,Europe/Moscow"
+ ];
+ [
+ "2104-12-01T01:08:00,Europe/Moscow"
+ ];
+ [
+ "2101-12-01T01:08:00,Europe/Moscow"
+ ];
+ [
+ "2105-11-01T01:08:00,Europe/Moscow"
+ ];
+ [
+ "2105-09-01T01:08:00,Europe/Moscow"
+ ]
];
[
- "2095-09-01T01:08:00,Europe/Moscow"
+ [
+ "2105-12-01T01:08:00,Europe/Moscow"
+ ];
+ #;
+ #;
+ #;
+ #;
+ #;
+ [
+ "2106-01-01T01:08:00,Europe/Moscow"
+ ];
+ #;
+ [
+ "2105-01-01T01:08:00,Europe/Moscow"
+ ];
+ [
+ "2095-09-01T01:08:00,Europe/Moscow"
+ ];
+ [
+ "2104-12-01T01:08:00,Europe/Moscow"
+ ];
+ [
+ "2101-12-01T01:08:00,Europe/Moscow"
+ ];
+ [
+ "2105-11-01T01:08:00,Europe/Moscow"
+ ];
+ [
+ "2105-09-01T01:08:00,Europe/Moscow"
+ ]
]
];
[
[
- "2059-06-13T00:00:00,GMT"
- ];
- [
- "2059-06-13T00:00:00,GMT"
- ];
- [
- "2053-06-13T00:00:00,GMT"
- ];
- [
- "2045-06-13T00:00:00,GMT"
- ];
- [
- "2049-06-13T00:00:00,GMT"
- ];
- [
- "2049-07-13T00:00:00,GMT"
- ];
- [
- "2049-09-13T00:00:00,GMT"
- ];
- [
- "2050-05-13T00:00:00,GMT"
- ];
- [
- "2050-06-13T00:00:00,GMT"
- ];
- [
- "2059-09-13T00:00:00,GMT"
- ];
- [
- "2049-05-13T00:00:00,GMT"
- ];
- [
- "2049-03-13T00:00:00,GMT"
- ];
- [
- "2048-07-13T00:00:00,GMT"
- ];
- [
- "2048-06-13T00:00:00,GMT"
+ [
+ "2049-06-13T00:00:00,GMT"
+ ];
+ [
+ "2059-06-13T00:00:00,GMT"
+ ];
+ [
+ "2050-05-13T00:00:00,GMT"
+ ];
+ [
+ "2059-09-13T00:00:00,GMT"
+ ];
+ [
+ "2050-06-13T00:00:00,GMT"
+ ];
+ [
+ "2053-06-13T00:00:00,GMT"
+ ];
+ [
+ "2049-07-13T00:00:00,GMT"
+ ];
+ [
+ "2049-09-13T00:00:00,GMT"
+ ];
+ [
+ "2048-07-13T00:00:00,GMT"
+ ];
+ [
+ "2039-03-13T00:00:00,GMT"
+ ];
+ [
+ "2048-06-13T00:00:00,GMT"
+ ];
+ [
+ "2045-06-13T00:00:00,GMT"
+ ];
+ [
+ "2049-05-13T00:00:00,GMT"
+ ];
+ [
+ "2049-03-13T00:00:00,GMT"
+ ]
];
[
- "2039-03-13T00:00:00,GMT"
+ [
+ "2049-06-13T00:00:00,GMT"
+ ];
+ [
+ "2059-06-13T00:00:00,GMT"
+ ];
+ [
+ "2050-05-13T00:00:00,GMT"
+ ];
+ [
+ "2059-09-13T00:00:00,GMT"
+ ];
+ [
+ "2050-06-13T00:00:00,GMT"
+ ];
+ [
+ "2053-06-13T00:00:00,GMT"
+ ];
+ [
+ "2049-07-13T00:00:00,GMT"
+ ];
+ [
+ "2049-09-13T00:00:00,GMT"
+ ];
+ [
+ "2048-07-13T00:00:00,GMT"
+ ];
+ [
+ "2039-03-13T00:00:00,GMT"
+ ];
+ [
+ "2048-06-13T00:00:00,GMT"
+ ];
+ [
+ "2045-06-13T00:00:00,GMT"
+ ];
+ [
+ "2049-05-13T00:00:00,GMT"
+ ];
+ [
+ "2049-03-13T00:00:00,GMT"
+ ]
]
];
[
[
- "2010-01-31T16:15:00,Europe/Uzhgorod"
- ];
- [
- "2010-01-31T16:15:00,Europe/Uzhgorod"
- ];
- [
- "2004-01-31T16:15:00,Europe/Uzhgorod"
- ];
- [
- "1996-01-31T16:15:00,Europe/Uzhgorod"
- ];
- [
- "2000-01-31T16:15:00,Europe/Uzhgorod"
- ];
- [
- "2000-02-29T16:15:00,Europe/Uzhgorod"
- ];
- [
- "2000-04-30T16:15:00,Europe/Uzhgorod"
- ];
- [
- "2000-12-31T16:15:00,Europe/Uzhgorod"
- ];
- [
- "2001-01-31T16:15:00,Europe/Uzhgorod"
- ];
- [
- "2010-04-30T16:15:00,Europe/Uzhgorod"
- ];
- [
- "1999-12-31T16:15:00,Europe/Uzhgorod"
- ];
- [
- "1999-10-31T16:15:00,Europe/Uzhgorod"
- ];
- [
- "1999-02-28T16:15:00,Europe/Uzhgorod"
- ];
- [
- "1999-01-31T16:15:00,Europe/Uzhgorod"
+ [
+ "2000-01-31T16:15:00,Europe/Uzhgorod"
+ ];
+ [
+ "2010-01-31T16:15:00,Europe/Uzhgorod"
+ ];
+ [
+ "2000-12-31T16:15:00,Europe/Uzhgorod"
+ ];
+ [
+ "2010-04-30T16:15:00,Europe/Uzhgorod"
+ ];
+ [
+ "2001-01-31T16:15:00,Europe/Uzhgorod"
+ ];
+ [
+ "2004-01-31T16:15:00,Europe/Uzhgorod"
+ ];
+ [
+ "2000-02-29T16:15:00,Europe/Uzhgorod"
+ ];
+ [
+ "2000-04-30T16:15:00,Europe/Uzhgorod"
+ ];
+ [
+ "1999-02-28T16:15:00,Europe/Uzhgorod"
+ ];
+ [
+ "1989-10-31T16:15:00,Europe/Uzhgorod"
+ ];
+ [
+ "1999-01-31T16:15:00,Europe/Uzhgorod"
+ ];
+ [
+ "1996-01-31T16:15:00,Europe/Uzhgorod"
+ ];
+ [
+ "1999-12-31T16:15:00,Europe/Uzhgorod"
+ ];
+ [
+ "1999-10-31T16:15:00,Europe/Uzhgorod"
+ ]
];
[
- "1989-10-31T16:15:00,Europe/Uzhgorod"
+ [
+ "2000-01-31T16:15:00,Europe/Uzhgorod"
+ ];
+ [
+ "2010-01-31T16:15:00,Europe/Uzhgorod"
+ ];
+ [
+ "2000-12-31T16:15:00,Europe/Uzhgorod"
+ ];
+ [
+ "2010-04-30T16:15:00,Europe/Uzhgorod"
+ ];
+ [
+ "2001-01-31T16:15:00,Europe/Uzhgorod"
+ ];
+ [
+ "2004-01-31T16:15:00,Europe/Uzhgorod"
+ ];
+ [
+ "2000-02-29T16:15:00,Europe/Uzhgorod"
+ ];
+ [
+ "2000-04-30T16:15:00,Europe/Uzhgorod"
+ ];
+ [
+ "1999-02-28T16:15:00,Europe/Uzhgorod"
+ ];
+ [
+ "1989-10-31T16:15:00,Europe/Uzhgorod"
+ ];
+ [
+ "1999-01-31T16:15:00,Europe/Uzhgorod"
+ ];
+ [
+ "1996-01-31T16:15:00,Europe/Uzhgorod"
+ ];
+ [
+ "1999-12-31T16:15:00,Europe/Uzhgorod"
+ ];
+ [
+ "1999-10-31T16:15:00,Europe/Uzhgorod"
+ ]
]
];
[
[
- "2034-02-28T01:02:03.456789,Europe/Moscow"
- ];
- [
- "2034-02-28T01:02:03.456789,Europe/Moscow"
- ];
- [
- "2028-02-29T01:02:03.456789,Europe/Moscow"
- ];
- [
- "2020-02-29T01:02:03.456789,Europe/Moscow"
- ];
- [
- "2024-02-29T01:02:03.456789,Europe/Moscow"
- ];
- [
- "2024-03-29T01:02:03.456789,Europe/Moscow"
- ];
- [
- "2024-05-29T01:02:03.456789,Europe/Moscow"
- ];
- [
- "2025-01-29T01:02:03.456789,Europe/Moscow"
- ];
- [
- "2025-02-28T01:02:03.456789,Europe/Moscow"
- ];
- [
- "2034-05-29T01:02:03.456789,Europe/Moscow"
- ];
- [
- "2024-01-29T01:02:03.456789,Europe/Moscow"
- ];
- [
- "2023-11-29T01:02:03.456789,Europe/Moscow"
- ];
- [
- "2023-03-29T01:02:03.456789,Europe/Moscow"
- ];
- [
- "2023-02-28T01:02:03.456789,Europe/Moscow"
+ [
+ "2024-02-29T01:02:03.456789,Europe/Moscow"
+ ];
+ [
+ "2034-02-28T01:02:03.456789,Europe/Moscow"
+ ];
+ [
+ "2025-01-29T01:02:03.456789,Europe/Moscow"
+ ];
+ [
+ "2034-05-29T01:02:03.456789,Europe/Moscow"
+ ];
+ [
+ "2025-02-28T01:02:03.456789,Europe/Moscow"
+ ];
+ [
+ "2028-02-29T01:02:03.456789,Europe/Moscow"
+ ];
+ [
+ "2024-03-29T01:02:03.456789,Europe/Moscow"
+ ];
+ [
+ "2024-05-29T01:02:03.456789,Europe/Moscow"
+ ];
+ [
+ "2023-03-29T01:02:03.456789,Europe/Moscow"
+ ];
+ [
+ "2013-11-29T01:02:03.456789,Europe/Moscow"
+ ];
+ [
+ "2023-02-28T01:02:03.456789,Europe/Moscow"
+ ];
+ [
+ "2020-02-29T01:02:03.456789,Europe/Moscow"
+ ];
+ [
+ "2024-01-29T01:02:03.456789,Europe/Moscow"
+ ];
+ [
+ "2023-11-29T01:02:03.456789,Europe/Moscow"
+ ]
];
[
- "2013-11-29T01:02:03.456789,Europe/Moscow"
+ [
+ "2024-02-29T01:02:03.456789,Europe/Moscow"
+ ];
+ [
+ "2034-02-28T01:02:03.456789,Europe/Moscow"
+ ];
+ [
+ "2025-01-29T01:02:03.456789,Europe/Moscow"
+ ];
+ [
+ "2034-05-29T01:02:03.456789,Europe/Moscow"
+ ];
+ [
+ "2025-02-28T01:02:03.456789,Europe/Moscow"
+ ];
+ [
+ "2028-02-29T01:02:03.456789,Europe/Moscow"
+ ];
+ [
+ "2024-03-29T01:02:03.456789,Europe/Moscow"
+ ];
+ [
+ "2024-05-29T01:02:03.456789,Europe/Moscow"
+ ];
+ [
+ "2023-03-29T01:02:03.456789,Europe/Moscow"
+ ];
+ [
+ "2013-11-29T01:02:03.456789,Europe/Moscow"
+ ];
+ [
+ "2023-02-28T01:02:03.456789,Europe/Moscow"
+ ];
+ [
+ "2020-02-29T01:02:03.456789,Europe/Moscow"
+ ];
+ [
+ "2024-01-29T01:02:03.456789,Europe/Moscow"
+ ];
+ [
+ "2023-11-29T01:02:03.456789,Europe/Moscow"
+ ]
]
];
[
[
- "1980-02-01T02:00:00.444123,Europe/Moscow"
- ];
- [
- "1980-02-01T02:00:00.444123,Europe/Moscow"
- ];
- [
- "1974-02-01T02:00:00.444123,Europe/Moscow"
- ];
- #;
- [
- "1970-02-01T02:00:00.444123,Europe/Moscow"
- ];
- [
- "1970-03-01T02:00:00.444123,Europe/Moscow"
- ];
- [
- "1970-05-01T02:00:00.444123,Europe/Moscow"
- ];
- [
- "1971-01-01T02:00:00.444123,Europe/Moscow"
- ];
- [
- "1971-02-01T02:00:00.444123,Europe/Moscow"
+ [
+ "1970-02-01T02:00:00.444123,Europe/Moscow"
+ ];
+ [
+ "1980-02-01T02:00:00.444123,Europe/Moscow"
+ ];
+ [
+ "1971-01-01T02:00:00.444123,Europe/Moscow"
+ ];
+ [
+ "1980-05-01T02:00:00.444123,Europe/Moscow"
+ ];
+ [
+ "1971-02-01T02:00:00.444123,Europe/Moscow"
+ ];
+ [
+ "1974-02-01T02:00:00.444123,Europe/Moscow"
+ ];
+ [
+ "1970-03-01T02:00:00.444123,Europe/Moscow"
+ ];
+ [
+ "1970-05-01T02:00:00.444123,Europe/Moscow"
+ ];
+ #;
+ #;
+ #;
+ #;
+ #;
+ #
];
[
- "1980-05-01T02:00:00.444123,Europe/Moscow"
- ];
- #;
- #;
- #;
- #;
- #
+ [
+ "1970-02-01T02:00:00.444123,Europe/Moscow"
+ ];
+ [
+ "1980-02-01T02:00:00.444123,Europe/Moscow"
+ ];
+ [
+ "1971-01-01T02:00:00.444123,Europe/Moscow"
+ ];
+ [
+ "1980-05-01T02:00:00.444123,Europe/Moscow"
+ ];
+ [
+ "1971-02-01T02:00:00.444123,Europe/Moscow"
+ ];
+ [
+ "1974-02-01T02:00:00.444123,Europe/Moscow"
+ ];
+ [
+ "1970-03-01T02:00:00.444123,Europe/Moscow"
+ ];
+ [
+ "1970-05-01T02:00:00.444123,Europe/Moscow"
+ ];
+ #;
+ #;
+ #;
+ #;
+ #;
+ #
+ ]
]
]
}
diff --git a/yql/essentials/udfs/common/datetime2/test/cases/Shift.sql b/yql/essentials/udfs/common/datetime2/test/cases/Shift.sql
index b421c558683..887c674f774 100644
--- a/yql/essentials/udfs/common/datetime2/test/cases/Shift.sql
+++ b/yql/essentials/udfs/common/datetime2/test/cases/Shift.sql
@@ -1,22 +1,31 @@
-SELECT
- cast(DateTime::MakeTzTimestamp(DateTime::ShiftYears(tm, 10)) as String),
- cast(DateTime::MakeTzTimestamp(DateTime::ShiftYears(tm, 10)) as String),
- cast(DateTime::MakeTzTimestamp(DateTime::ShiftQuarters(tm, 16)) as String),
- cast(DateTime::MakeTzTimestamp(DateTime::ShiftQuarters(tm, -16)) as String),
- cast(DateTime::MakeTzTimestamp(DateTime::ShiftMonths(tm, 0)) as String),
- cast(DateTime::MakeTzTimestamp(DateTime::ShiftMonths(tm, 1)) as String),
- cast(DateTime::MakeTzTimestamp(DateTime::ShiftMonths(tm, 3)) as String),
- cast(DateTime::MakeTzTimestamp(DateTime::ShiftMonths(tm, 11)) as String),
- cast(DateTime::MakeTzTimestamp(DateTime::ShiftMonths(tm, 12)) as String),
- cast(DateTime::MakeTzTimestamp(DateTime::ShiftMonths(tm, 123)) as String),
- cast(DateTime::MakeTzTimestamp(DateTime::ShiftMonths(tm, -1)) as String),
- cast(DateTime::MakeTzTimestamp(DateTime::ShiftMonths(tm, -3)) as String),
- cast(DateTime::MakeTzTimestamp(DateTime::ShiftMonths(tm, -11)) as String),
- cast(DateTime::MakeTzTimestamp(DateTime::ShiftMonths(tm, -12)) as String),
- cast(DateTime::MakeTzTimestamp(DateTime::ShiftMonths(tm, -123)) as String)
-from (
- select
- cast(ftztimestamp as TzTimestamp) as tm
- from Input
-);
+/* syntax version 1 */
+$check = ($arg) -> {
+ return <|
+ sh10y: CAST(DateTime::MakeTzTimestamp(DateTime::ShiftYears($arg, 10)) as String),
+ sh16q: CAST(DateTime::MakeTzTimestamp(DateTime::ShiftQuarters($arg, 16)) as String),
+ shm16q: CAST(DateTime::MakeTzTimestamp(DateTime::ShiftQuarters($arg, -16)) as String),
+ sh0m: CAST(DateTime::MakeTzTimestamp(DateTime::ShiftMonths($arg, 0)) as String),
+ sh1m: CAST(DateTime::MakeTzTimestamp(DateTime::ShiftMonths($arg, 1)) as String),
+ sh3m: CAST(DateTime::MakeTzTimestamp(DateTime::ShiftMonths($arg, 3)) as String),
+ sh11m: CAST(DateTime::MakeTzTimestamp(DateTime::ShiftMonths($arg, 11)) as String),
+ sh12m: CAST(DateTime::MakeTzTimestamp(DateTime::ShiftMonths($arg, 12)) as String),
+ sh123m: CAST(DateTime::MakeTzTimestamp(DateTime::ShiftMonths($arg, 123)) as String),
+ shm1m: CAST(DateTime::MakeTzTimestamp(DateTime::ShiftMonths($arg, -1)) as String),
+ shm3m: CAST(DateTime::MakeTzTimestamp(DateTime::ShiftMonths($arg, -3)) as String),
+ shm11m: CAST(DateTime::MakeTzTimestamp(DateTime::ShiftMonths($arg, -11)) as String),
+ shm12m: CAST(DateTime::MakeTzTimestamp(DateTime::ShiftMonths($arg, -12)) as String),
+ shm123m: CAST(DateTime::MakeTzTimestamp(DateTime::ShiftMonths($arg, -123)) as String),
+ |>
+};
+$typeDispatcher = ($row) -> {
+ $tm = $row.tm;
+ return <|
+ explicit: $check(DateTime::Split($tm)),
+ implicit: $check($tm),
+ |>;
+};
+
+$input = SELECT CAST(ftztimestamp as TzTimestamp) as tm FROM Input;
+
+PROCESS $input USING $typeDispatcher(TableRow());
diff --git a/yql/essentials/udfs/common/datetime2/test_bigdates/canondata/result.json b/yql/essentials/udfs/common/datetime2/test_bigdates/canondata/result.json
index 01840317a7d..3b6fd324643 100644
--- a/yql/essentials/udfs/common/datetime2/test_bigdates/canondata/result.json
+++ b/yql/essentials/udfs/common/datetime2/test_bigdates/canondata/result.json
@@ -19,6 +19,11 @@
"uri": "file://test.test_Get_/results.txt"
}
],
+ "test.test[Shift]": [
+ {
+ "uri": "file://test.test_Shift_/results.txt"
+ }
+ ],
"test.test[SplitMake]": [
{
"uri": "file://test.test_SplitMake_/results.txt"
diff --git a/yql/essentials/udfs/common/datetime2/test_bigdates/canondata/test.test_Shift_/results.txt b/yql/essentials/udfs/common/datetime2/test_bigdates/canondata/test.test_Shift_/results.txt
new file mode 100644
index 00000000000..7bf839a0907
--- /dev/null
+++ b/yql/essentials/udfs/common/datetime2/test_bigdates/canondata/test.test_Shift_/results.txt
@@ -0,0 +1,982 @@
+[
+ {
+ "Write" = [
+ {
+ "Type" = [
+ "ListType";
+ [
+ "StructType";
+ [
+ [
+ "explicit";
+ [
+ "StructType";
+ [
+ [
+ "sh0m";
+ [
+ "OptionalType";
+ [
+ "DataType";
+ "String"
+ ]
+ ]
+ ];
+ [
+ "sh10y";
+ [
+ "OptionalType";
+ [
+ "DataType";
+ "String"
+ ]
+ ]
+ ];
+ [
+ "sh11m";
+ [
+ "OptionalType";
+ [
+ "DataType";
+ "String"
+ ]
+ ]
+ ];
+ [
+ "sh123m";
+ [
+ "OptionalType";
+ [
+ "DataType";
+ "String"
+ ]
+ ]
+ ];
+ [
+ "sh12m";
+ [
+ "OptionalType";
+ [
+ "DataType";
+ "String"
+ ]
+ ]
+ ];
+ [
+ "sh16q";
+ [
+ "OptionalType";
+ [
+ "DataType";
+ "String"
+ ]
+ ]
+ ];
+ [
+ "sh1m";
+ [
+ "OptionalType";
+ [
+ "DataType";
+ "String"
+ ]
+ ]
+ ];
+ [
+ "sh3m";
+ [
+ "OptionalType";
+ [
+ "DataType";
+ "String"
+ ]
+ ]
+ ];
+ [
+ "shm11m";
+ [
+ "OptionalType";
+ [
+ "DataType";
+ "String"
+ ]
+ ]
+ ];
+ [
+ "shm123m";
+ [
+ "OptionalType";
+ [
+ "DataType";
+ "String"
+ ]
+ ]
+ ];
+ [
+ "shm12m";
+ [
+ "OptionalType";
+ [
+ "DataType";
+ "String"
+ ]
+ ]
+ ];
+ [
+ "shm16q";
+ [
+ "OptionalType";
+ [
+ "DataType";
+ "String"
+ ]
+ ]
+ ];
+ [
+ "shm1m";
+ [
+ "OptionalType";
+ [
+ "DataType";
+ "String"
+ ]
+ ]
+ ];
+ [
+ "shm3m";
+ [
+ "OptionalType";
+ [
+ "DataType";
+ "String"
+ ]
+ ]
+ ]
+ ]
+ ]
+ ];
+ [
+ "implicit";
+ [
+ "StructType";
+ [
+ [
+ "sh0m";
+ [
+ "OptionalType";
+ [
+ "DataType";
+ "String"
+ ]
+ ]
+ ];
+ [
+ "sh10y";
+ [
+ "OptionalType";
+ [
+ "DataType";
+ "String"
+ ]
+ ]
+ ];
+ [
+ "sh11m";
+ [
+ "OptionalType";
+ [
+ "DataType";
+ "String"
+ ]
+ ]
+ ];
+ [
+ "sh123m";
+ [
+ "OptionalType";
+ [
+ "DataType";
+ "String"
+ ]
+ ]
+ ];
+ [
+ "sh12m";
+ [
+ "OptionalType";
+ [
+ "DataType";
+ "String"
+ ]
+ ]
+ ];
+ [
+ "sh16q";
+ [
+ "OptionalType";
+ [
+ "DataType";
+ "String"
+ ]
+ ]
+ ];
+ [
+ "sh1m";
+ [
+ "OptionalType";
+ [
+ "DataType";
+ "String"
+ ]
+ ]
+ ];
+ [
+ "sh3m";
+ [
+ "OptionalType";
+ [
+ "DataType";
+ "String"
+ ]
+ ]
+ ];
+ [
+ "shm11m";
+ [
+ "OptionalType";
+ [
+ "DataType";
+ "String"
+ ]
+ ]
+ ];
+ [
+ "shm123m";
+ [
+ "OptionalType";
+ [
+ "DataType";
+ "String"
+ ]
+ ]
+ ];
+ [
+ "shm12m";
+ [
+ "OptionalType";
+ [
+ "DataType";
+ "String"
+ ]
+ ]
+ ];
+ [
+ "shm16q";
+ [
+ "OptionalType";
+ [
+ "DataType";
+ "String"
+ ]
+ ]
+ ];
+ [
+ "shm1m";
+ [
+ "OptionalType";
+ [
+ "DataType";
+ "String"
+ ]
+ ]
+ ];
+ [
+ "shm3m";
+ [
+ "OptionalType";
+ [
+ "DataType";
+ "String"
+ ]
+ ]
+ ]
+ ]
+ ]
+ ]
+ ]
+ ]
+ ];
+ "Data" = [
+ [
+ [
+ [
+ "-144169-01-01T00:00:00Z"
+ ];
+ [
+ "-144159-01-01T00:00:00Z"
+ ];
+ [
+ "-144169-12-01T00:00:00Z"
+ ];
+ [
+ "-144159-04-01T00:00:00Z"
+ ];
+ [
+ "-144168-01-01T00:00:00Z"
+ ];
+ [
+ "-144165-01-01T00:00:00Z"
+ ];
+ [
+ "-144169-02-01T00:00:00Z"
+ ];
+ [
+ "-144169-04-01T00:00:00Z"
+ ];
+ #;
+ #;
+ #;
+ #;
+ #;
+ #
+ ];
+ [
+ [
+ "-144169-01-01T00:00:00Z"
+ ];
+ [
+ "-144159-01-01T00:00:00Z"
+ ];
+ [
+ "-144169-12-01T00:00:00Z"
+ ];
+ [
+ "-144159-04-01T00:00:00Z"
+ ];
+ [
+ "-144168-01-01T00:00:00Z"
+ ];
+ [
+ "-144165-01-01T00:00:00Z"
+ ];
+ [
+ "-144169-02-01T00:00:00Z"
+ ];
+ [
+ "-144169-04-01T00:00:00Z"
+ ];
+ #;
+ #;
+ #;
+ #;
+ #;
+ #
+ ]
+ ];
+ [
+ [
+ [
+ "-1-01-01T23:59:59.999999Z"
+ ];
+ [
+ "9-01-01T23:59:59.999999Z"
+ ];
+ [
+ "-1-12-01T23:59:59.999999Z"
+ ];
+ [
+ "9-04-01T23:59:59.999999Z"
+ ];
+ [
+ "1-01-01T23:59:59.999999Z"
+ ];
+ [
+ "3-01-01T23:59:59.999999Z"
+ ];
+ [
+ "-1-02-01T23:59:59.999999Z"
+ ];
+ [
+ "-1-04-01T23:59:59.999999Z"
+ ];
+ [
+ "-2-02-01T23:59:59.999999Z"
+ ];
+ [
+ "-12-10-01T23:59:59.999999Z"
+ ];
+ [
+ "-2-01-01T23:59:59.999999Z"
+ ];
+ [
+ "-5-01-01T23:59:59.999999Z"
+ ];
+ [
+ "-2-12-01T23:59:59.999999Z"
+ ];
+ [
+ "-2-10-01T23:59:59.999999Z"
+ ]
+ ];
+ [
+ [
+ "-1-01-01T23:59:59.999999Z"
+ ];
+ [
+ "9-01-01T23:59:59.999999Z"
+ ];
+ [
+ "-1-12-01T23:59:59.999999Z"
+ ];
+ [
+ "9-04-01T23:59:59.999999Z"
+ ];
+ [
+ "1-01-01T23:59:59.999999Z"
+ ];
+ [
+ "3-01-01T23:59:59.999999Z"
+ ];
+ [
+ "-1-02-01T23:59:59.999999Z"
+ ];
+ [
+ "-1-04-01T23:59:59.999999Z"
+ ];
+ [
+ "-2-02-01T23:59:59.999999Z"
+ ];
+ [
+ "-12-10-01T23:59:59.999999Z"
+ ];
+ [
+ "-2-01-01T23:59:59.999999Z"
+ ];
+ [
+ "-5-01-01T23:59:59.999999Z"
+ ];
+ [
+ "-2-12-01T23:59:59.999999Z"
+ ];
+ [
+ "-2-10-01T23:59:59.999999Z"
+ ]
+ ]
+ ];
+ [
+ [
+ [
+ "1-01-01T00:00:00Z"
+ ];
+ [
+ "11-01-01T00:00:00Z"
+ ];
+ [
+ "1-12-01T00:00:00Z"
+ ];
+ [
+ "11-04-01T00:00:00Z"
+ ];
+ [
+ "2-01-01T00:00:00Z"
+ ];
+ [
+ "5-01-01T00:00:00Z"
+ ];
+ [
+ "1-02-01T00:00:00Z"
+ ];
+ [
+ "1-04-01T00:00:00Z"
+ ];
+ [
+ "-1-02-01T00:00:00Z"
+ ];
+ [
+ "-10-10-01T00:00:00Z"
+ ];
+ [
+ "-1-01-01T00:00:00Z"
+ ];
+ [
+ "-3-01-01T00:00:00Z"
+ ];
+ [
+ "-1-12-01T00:00:00Z"
+ ];
+ [
+ "-1-10-01T00:00:00Z"
+ ]
+ ];
+ [
+ [
+ "1-01-01T00:00:00Z"
+ ];
+ [
+ "11-01-01T00:00:00Z"
+ ];
+ [
+ "1-12-01T00:00:00Z"
+ ];
+ [
+ "11-04-01T00:00:00Z"
+ ];
+ [
+ "2-01-01T00:00:00Z"
+ ];
+ [
+ "5-01-01T00:00:00Z"
+ ];
+ [
+ "1-02-01T00:00:00Z"
+ ];
+ [
+ "1-04-01T00:00:00Z"
+ ];
+ [
+ "-1-02-01T00:00:00Z"
+ ];
+ [
+ "-10-10-01T00:00:00Z"
+ ];
+ [
+ "-1-01-01T00:00:00Z"
+ ];
+ [
+ "-3-01-01T00:00:00Z"
+ ];
+ [
+ "-1-12-01T00:00:00Z"
+ ];
+ [
+ "-1-10-01T00:00:00Z"
+ ]
+ ]
+ ];
+ [
+ [
+ [
+ "1969-12-31T23:59:59.999999Z"
+ ];
+ [
+ "1979-12-31T23:59:59.999999Z"
+ ];
+ [
+ "1970-11-30T23:59:59.999999Z"
+ ];
+ [
+ "1980-03-31T23:59:59.999999Z"
+ ];
+ [
+ "1970-12-31T23:59:59.999999Z"
+ ];
+ [
+ "1973-12-31T23:59:59.999999Z"
+ ];
+ [
+ "1970-01-31T23:59:59.999999Z"
+ ];
+ [
+ "1970-03-31T23:59:59.999999Z"
+ ];
+ [
+ "1969-01-31T23:59:59.999999Z"
+ ];
+ [
+ "1959-09-30T23:59:59.999999Z"
+ ];
+ [
+ "1968-12-31T23:59:59.999999Z"
+ ];
+ [
+ "1965-12-31T23:59:59.999999Z"
+ ];
+ [
+ "1969-11-30T23:59:59.999999Z"
+ ];
+ [
+ "1969-09-30T23:59:59.999999Z"
+ ]
+ ];
+ [
+ [
+ "1969-12-31T23:59:59.999999Z"
+ ];
+ [
+ "1979-12-31T23:59:59.999999Z"
+ ];
+ [
+ "1970-11-30T23:59:59.999999Z"
+ ];
+ [
+ "1980-03-31T23:59:59.999999Z"
+ ];
+ [
+ "1970-12-31T23:59:59.999999Z"
+ ];
+ [
+ "1973-12-31T23:59:59.999999Z"
+ ];
+ [
+ "1970-01-31T23:59:59.999999Z"
+ ];
+ [
+ "1970-03-31T23:59:59.999999Z"
+ ];
+ [
+ "1969-01-31T23:59:59.999999Z"
+ ];
+ [
+ "1959-09-30T23:59:59.999999Z"
+ ];
+ [
+ "1968-12-31T23:59:59.999999Z"
+ ];
+ [
+ "1965-12-31T23:59:59.999999Z"
+ ];
+ [
+ "1969-11-30T23:59:59.999999Z"
+ ];
+ [
+ "1969-09-30T23:59:59.999999Z"
+ ]
+ ]
+ ];
+ [
+ [
+ [
+ "1970-01-01T00:00:00Z"
+ ];
+ [
+ "1980-01-01T00:00:00Z"
+ ];
+ [
+ "1970-12-01T00:00:00Z"
+ ];
+ [
+ "1980-04-01T00:00:00Z"
+ ];
+ [
+ "1971-01-01T00:00:00Z"
+ ];
+ [
+ "1974-01-01T00:00:00Z"
+ ];
+ [
+ "1970-02-01T00:00:00Z"
+ ];
+ [
+ "1970-04-01T00:00:00Z"
+ ];
+ [
+ "1969-02-01T00:00:00Z"
+ ];
+ [
+ "1959-10-01T00:00:00Z"
+ ];
+ [
+ "1969-01-01T00:00:00Z"
+ ];
+ [
+ "1966-01-01T00:00:00Z"
+ ];
+ [
+ "1969-12-01T00:00:00Z"
+ ];
+ [
+ "1969-10-01T00:00:00Z"
+ ]
+ ];
+ [
+ [
+ "1970-01-01T00:00:00Z"
+ ];
+ [
+ "1980-01-01T00:00:00Z"
+ ];
+ [
+ "1970-12-01T00:00:00Z"
+ ];
+ [
+ "1980-04-01T00:00:00Z"
+ ];
+ [
+ "1971-01-01T00:00:00Z"
+ ];
+ [
+ "1974-01-01T00:00:00Z"
+ ];
+ [
+ "1970-02-01T00:00:00Z"
+ ];
+ [
+ "1970-04-01T00:00:00Z"
+ ];
+ [
+ "1969-02-01T00:00:00Z"
+ ];
+ [
+ "1959-10-01T00:00:00Z"
+ ];
+ [
+ "1969-01-01T00:00:00Z"
+ ];
+ [
+ "1966-01-01T00:00:00Z"
+ ];
+ [
+ "1969-12-01T00:00:00Z"
+ ];
+ [
+ "1969-10-01T00:00:00Z"
+ ]
+ ]
+ ];
+ [
+ [
+ [
+ "2025-01-01T00:00:00Z"
+ ];
+ [
+ "2035-01-01T00:00:00Z"
+ ];
+ [
+ "2025-12-01T00:00:00Z"
+ ];
+ [
+ "2035-04-01T00:00:00Z"
+ ];
+ [
+ "2026-01-01T00:00:00Z"
+ ];
+ [
+ "2029-01-01T00:00:00Z"
+ ];
+ [
+ "2025-02-01T00:00:00Z"
+ ];
+ [
+ "2025-04-01T00:00:00Z"
+ ];
+ [
+ "2024-02-01T00:00:00Z"
+ ];
+ [
+ "2014-10-01T00:00:00Z"
+ ];
+ [
+ "2024-01-01T00:00:00Z"
+ ];
+ [
+ "2021-01-01T00:00:00Z"
+ ];
+ [
+ "2024-12-01T00:00:00Z"
+ ];
+ [
+ "2024-10-01T00:00:00Z"
+ ]
+ ];
+ [
+ [
+ "2025-01-01T00:00:00Z"
+ ];
+ [
+ "2035-01-01T00:00:00Z"
+ ];
+ [
+ "2025-12-01T00:00:00Z"
+ ];
+ [
+ "2035-04-01T00:00:00Z"
+ ];
+ [
+ "2026-01-01T00:00:00Z"
+ ];
+ [
+ "2029-01-01T00:00:00Z"
+ ];
+ [
+ "2025-02-01T00:00:00Z"
+ ];
+ [
+ "2025-04-01T00:00:00Z"
+ ];
+ [
+ "2024-02-01T00:00:00Z"
+ ];
+ [
+ "2014-10-01T00:00:00Z"
+ ];
+ [
+ "2024-01-01T00:00:00Z"
+ ];
+ [
+ "2021-01-01T00:00:00Z"
+ ];
+ [
+ "2024-12-01T00:00:00Z"
+ ];
+ [
+ "2024-10-01T00:00:00Z"
+ ]
+ ]
+ ];
+ [
+ [
+ [
+ "2106-01-01T00:00:00Z"
+ ];
+ [
+ "2116-01-01T00:00:00Z"
+ ];
+ [
+ "2106-12-01T00:00:00Z"
+ ];
+ [
+ "2116-04-01T00:00:00Z"
+ ];
+ [
+ "2107-01-01T00:00:00Z"
+ ];
+ [
+ "2110-01-01T00:00:00Z"
+ ];
+ [
+ "2106-02-01T00:00:00Z"
+ ];
+ [
+ "2106-04-01T00:00:00Z"
+ ];
+ [
+ "2105-02-01T00:00:00Z"
+ ];
+ [
+ "2095-10-01T00:00:00Z"
+ ];
+ [
+ "2105-01-01T00:00:00Z"
+ ];
+ [
+ "2102-01-01T00:00:00Z"
+ ];
+ [
+ "2105-12-01T00:00:00Z"
+ ];
+ [
+ "2105-10-01T00:00:00Z"
+ ]
+ ];
+ [
+ [
+ "2106-01-01T00:00:00Z"
+ ];
+ [
+ "2116-01-01T00:00:00Z"
+ ];
+ [
+ "2106-12-01T00:00:00Z"
+ ];
+ [
+ "2116-04-01T00:00:00Z"
+ ];
+ [
+ "2107-01-01T00:00:00Z"
+ ];
+ [
+ "2110-01-01T00:00:00Z"
+ ];
+ [
+ "2106-02-01T00:00:00Z"
+ ];
+ [
+ "2106-04-01T00:00:00Z"
+ ];
+ [
+ "2105-02-01T00:00:00Z"
+ ];
+ [
+ "2095-10-01T00:00:00Z"
+ ];
+ [
+ "2105-01-01T00:00:00Z"
+ ];
+ [
+ "2102-01-01T00:00:00Z"
+ ];
+ [
+ "2105-12-01T00:00:00Z"
+ ];
+ [
+ "2105-10-01T00:00:00Z"
+ ]
+ ]
+ ];
+ [
+ [
+ [
+ "148107-12-31T23:59:59.999999Z"
+ ];
+ #;
+ #;
+ #;
+ #;
+ #;
+ #;
+ #;
+ [
+ "148107-01-31T23:59:59.999999Z"
+ ];
+ [
+ "148097-09-30T23:59:59.999999Z"
+ ];
+ [
+ "148106-12-31T23:59:59.999999Z"
+ ];
+ [
+ "148103-12-31T23:59:59.999999Z"
+ ];
+ [
+ "148107-11-30T23:59:59.999999Z"
+ ];
+ [
+ "148107-09-30T23:59:59.999999Z"
+ ]
+ ];
+ [
+ [
+ "148107-12-31T23:59:59.999999Z"
+ ];
+ #;
+ #;
+ #;
+ #;
+ #;
+ #;
+ #;
+ [
+ "148107-01-31T23:59:59.999999Z"
+ ];
+ [
+ "148097-09-30T23:59:59.999999Z"
+ ];
+ [
+ "148106-12-31T23:59:59.999999Z"
+ ];
+ [
+ "148103-12-31T23:59:59.999999Z"
+ ];
+ [
+ "148107-11-30T23:59:59.999999Z"
+ ];
+ [
+ "148107-09-30T23:59:59.999999Z"
+ ]
+ ]
+ ]
+ ]
+ }
+ ]
+ }
+] \ No newline at end of file
diff --git a/yql/essentials/udfs/common/datetime2/test_bigdates/cases/Shift.cfg b/yql/essentials/udfs/common/datetime2/test_bigdates/cases/Shift.cfg
new file mode 100644
index 00000000000..4171e413f3f
--- /dev/null
+++ b/yql/essentials/udfs/common/datetime2/test_bigdates/cases/Shift.cfg
@@ -0,0 +1 @@
+in plato.Input Shift.in
diff --git a/yql/essentials/udfs/common/datetime2/test_bigdates/cases/Shift.in b/yql/essentials/udfs/common/datetime2/test_bigdates/cases/Shift.in
new file mode 100644
index 00000000000..4eb94e06a48
--- /dev/null
+++ b/yql/essentials/udfs/common/datetime2/test_bigdates/cases/Shift.in
@@ -0,0 +1,8 @@
+{"ftimestamp64"="-144169-01-01T00:00:00.000000Z"};
+{"ftimestamp64"="-1-01-01T23:59:59.999999Z"};
+{"ftimestamp64"="1-01-01T00:00:00.000000Z"};
+{"ftimestamp64"="1969-12-31T23:59:59.999999Z"};
+{"ftimestamp64"="1970-01-01T00:00:00.000000Z"};
+{"ftimestamp64"="2025-01-01T00:00:00.000000Z"};
+{"ftimestamp64"="2106-01-01T00:00:00.000000Z"};
+{"ftimestamp64"="148107-12-31T23:59:59.999999Z"};
diff --git a/yql/essentials/udfs/common/datetime2/test_bigdates/cases/Shift.in.attr b/yql/essentials/udfs/common/datetime2/test_bigdates/cases/Shift.in.attr
new file mode 100644
index 00000000000..91994000ceb
--- /dev/null
+++ b/yql/essentials/udfs/common/datetime2/test_bigdates/cases/Shift.in.attr
@@ -0,0 +1,16 @@
+{
+ "_yql_row_spec" = {
+ "Type" = [
+ "StructType";
+ [
+ [
+ "ftimestamp64";
+ [
+ "DataType";
+ "String"
+ ]
+ ]
+ ]
+ ]
+ }
+}
diff --git a/yql/essentials/udfs/common/datetime2/test_bigdates/cases/Shift.sql b/yql/essentials/udfs/common/datetime2/test_bigdates/cases/Shift.sql
new file mode 100644
index 00000000000..bfff8a6e6e2
--- /dev/null
+++ b/yql/essentials/udfs/common/datetime2/test_bigdates/cases/Shift.sql
@@ -0,0 +1,31 @@
+/* syntax version 1 */
+$check = ($arg) -> {
+ return <|
+ sh10y: CAST(DateTime::MakeTimestamp64(DateTime::ShiftYears($arg, 10)) as String),
+ sh16q: CAST(DateTime::MakeTimestamp64(DateTime::ShiftQuarters($arg, 16)) as String),
+ shm16q: CAST(DateTime::MakeTimestamp64(DateTime::ShiftQuarters($arg, -16)) as String),
+ sh0m: CAST(DateTime::MakeTimestamp64(DateTime::ShiftMonths($arg, 0)) as String),
+ sh1m: CAST(DateTime::MakeTimestamp64(DateTime::ShiftMonths($arg, 1)) as String),
+ sh3m: CAST(DateTime::MakeTimestamp64(DateTime::ShiftMonths($arg, 3)) as String),
+ sh11m: CAST(DateTime::MakeTimestamp64(DateTime::ShiftMonths($arg, 11)) as String),
+ sh12m: CAST(DateTime::MakeTimestamp64(DateTime::ShiftMonths($arg, 12)) as String),
+ sh123m: CAST(DateTime::MakeTimestamp64(DateTime::ShiftMonths($arg, 123)) as String),
+ shm1m: CAST(DateTime::MakeTimestamp64(DateTime::ShiftMonths($arg, -1)) as String),
+ shm3m: CAST(DateTime::MakeTimestamp64(DateTime::ShiftMonths($arg, -3)) as String),
+ shm11m: CAST(DateTime::MakeTimestamp64(DateTime::ShiftMonths($arg, -11)) as String),
+ shm12m: CAST(DateTime::MakeTimestamp64(DateTime::ShiftMonths($arg, -12)) as String),
+ shm123m: CAST(DateTime::MakeTimestamp64(DateTime::ShiftMonths($arg, -123)) as String),
+ |>
+};
+
+$typeDispatcher = ($row) -> {
+ $tm = $row.tm;
+ return <|
+ explicit: $check(DateTime::Split($tm)),
+ implicit: $check($tm),
+ |>;
+};
+
+$input = SELECT CAST(ftimestamp64 as Timestamp64) as tm FROM Input;
+
+PROCESS $input USING $typeDispatcher(TableRow());