diff options
author | aneporada <aneporada@ydb.tech> | 2023-01-24 12:00:57 +0300 |
---|---|---|
committer | aneporada <aneporada@ydb.tech> | 2023-01-24 12:00:57 +0300 |
commit | 819ad9fa58cbc40b06851149cf52672814ddecd5 (patch) | |
tree | a6815d9b65894bd136d378361d7a42420c4d512c | |
parent | 605baa4c326c4b7bf0a4f4b5434a4dad8066d0d5 (diff) | |
download | ydb-819ad9fa58cbc40b06851149cf52672814ddecd5.tar.gz |
Mark UDF strictness for datetime & datetime2
8 files changed, 120 insertions, 118 deletions
diff --git a/ydb/library/yql/udfs/common/datetime/CMakeLists.darwin.txt b/ydb/library/yql/udfs/common/datetime/CMakeLists.darwin.txt index c14be7d04c..6ea3c445e9 100644 --- a/ydb/library/yql/udfs/common/datetime/CMakeLists.darwin.txt +++ b/ydb/library/yql/udfs/common/datetime/CMakeLists.darwin.txt @@ -20,7 +20,7 @@ target_link_libraries(datetime_udf INTERFACE add_global_library_for(datetime_udf.global datetime_udf) target_compile_options(datetime_udf.global PRIVATE -DUDF_ABI_VERSION_MAJOR=2 - -DUDF_ABI_VERSION_MINOR=27 + -DUDF_ABI_VERSION_MINOR=28 -DUDF_ABI_VERSION_PATCH=0 ) target_link_libraries(datetime_udf.global PUBLIC diff --git a/ydb/library/yql/udfs/common/datetime/CMakeLists.linux-aarch64.txt b/ydb/library/yql/udfs/common/datetime/CMakeLists.linux-aarch64.txt index e6f6af51fc..afa32f5b37 100644 --- a/ydb/library/yql/udfs/common/datetime/CMakeLists.linux-aarch64.txt +++ b/ydb/library/yql/udfs/common/datetime/CMakeLists.linux-aarch64.txt @@ -21,7 +21,7 @@ target_link_libraries(datetime_udf INTERFACE add_global_library_for(datetime_udf.global datetime_udf) target_compile_options(datetime_udf.global PRIVATE -DUDF_ABI_VERSION_MAJOR=2 - -DUDF_ABI_VERSION_MINOR=27 + -DUDF_ABI_VERSION_MINOR=28 -DUDF_ABI_VERSION_PATCH=0 ) target_link_libraries(datetime_udf.global PUBLIC diff --git a/ydb/library/yql/udfs/common/datetime/CMakeLists.linux.txt b/ydb/library/yql/udfs/common/datetime/CMakeLists.linux.txt index e6f6af51fc..afa32f5b37 100644 --- a/ydb/library/yql/udfs/common/datetime/CMakeLists.linux.txt +++ b/ydb/library/yql/udfs/common/datetime/CMakeLists.linux.txt @@ -21,7 +21,7 @@ target_link_libraries(datetime_udf INTERFACE add_global_library_for(datetime_udf.global datetime_udf) target_compile_options(datetime_udf.global PRIVATE -DUDF_ABI_VERSION_MAJOR=2 - -DUDF_ABI_VERSION_MINOR=27 + -DUDF_ABI_VERSION_MINOR=28 -DUDF_ABI_VERSION_PATCH=0 ) target_link_libraries(datetime_udf.global PUBLIC diff --git a/ydb/library/yql/udfs/common/datetime/datetime_udf.cpp b/ydb/library/yql/udfs/common/datetime/datetime_udf.cpp index 01567c0b1b..3bf67b22ea 100644 --- a/ydb/library/yql/udfs/common/datetime/datetime_udf.cpp +++ b/ydb/library/yql/udfs/common/datetime/datetime_udf.cpp @@ -13,19 +13,19 @@ using namespace NUdf; using namespace NDatetime; namespace { - SIMPLE_UDF(TToString, char*(TAutoMap<TTimestamp>)) { + SIMPLE_STRICT_UDF(TToString, char*(TAutoMap<TTimestamp>)) { const auto input = args[0].Get<ui64>(); TInstant instant = TInstant::MicroSeconds(input); return valueBuilder->NewString(instant.ToString()); } - SIMPLE_UDF(TToStringUpToSeconds, char*(TAutoMap<TTimestamp>)) { + SIMPLE_STRICT_UDF(TToStringUpToSeconds, char*(TAutoMap<TTimestamp>)) { const auto input = args[0].Get<ui64>(); TInstant instant = TInstant::MicroSeconds(input); return valueBuilder->NewString(instant.ToStringUpToSeconds()); } - SIMPLE_UDF(TToStringFormat, char*(TAutoMap<TTimestamp>, char*)) { + SIMPLE_STRICT_UDF(TToStringFormat, char*(TAutoMap<TTimestamp>, char*)) { const auto input = args[0].Get<ui64>(); const TString format(args[1].AsStringRef()); TInstant instant = TInstant::MicroSeconds(input); @@ -33,7 +33,7 @@ namespace { return valueBuilder->NewString(tm.ToString(format.c_str())); } - SIMPLE_UDF(TToDate, char*(TAutoMap<TTimestamp>)) { + SIMPLE_STRICT_UDF(TToDate, char*(TAutoMap<TTimestamp>)) { const auto input = args[0].Get<ui64>(); TInstant instant = TInstant::MicroSeconds(input); TSimpleTM tm = TSimpleTM::New(static_cast<time_t>(instant.Seconds())); @@ -76,7 +76,7 @@ namespace { return TUnboxedValuePod(result); } - SIMPLE_UDF(TIsWeekend, bool(TAutoMap<TTimestamp>)) { + SIMPLE_STRICT_UDF(TIsWeekend, bool(TAutoMap<TTimestamp>)) { Y_UNUSED(valueBuilder); const auto input = args[0].Get<ui64>(); TInstant instant = TInstant::MicroSeconds(input); @@ -149,12 +149,12 @@ namespace { return success ? TUnboxedValuePod(result.MicroSeconds() + bonus) : TUnboxedValuePod(); } - SIMPLE_UDF(TFromString, TOptional<ui64>(TOptional<char*>)) { + SIMPLE_STRICT_UDF(TFromString, TOptional<ui64>(TOptional<char*>)) { Y_UNUSED(valueBuilder); return FromStringImpl(args); } - SIMPLE_UDF(TTimestampFromString, TOptional<TTimestamp>(TOptional<char*>)) { + SIMPLE_STRICT_UDF(TTimestampFromString, TOptional<TTimestamp>(TOptional<char*>)) { Y_UNUSED(valueBuilder); return FromStringImpl(args); } @@ -169,42 +169,42 @@ namespace { return success ? TUnboxedValuePod(result.MicroSeconds()) : TUnboxedValuePod(); } - SIMPLE_UDF(TFromStringFormat, TOptional<ui64>(TOptional<char*>, char*)) { + SIMPLE_STRICT_UDF(TFromStringFormat, TOptional<ui64>(TOptional<char*>, char*)) { Y_UNUSED(valueBuilder); return FromStringFormatImpl(args); } - SIMPLE_UDF(TTimestampFromStringFormat, TOptional<TTimestamp>(TOptional<char*>, char*)) { + SIMPLE_STRICT_UDF(TTimestampFromStringFormat, TOptional<TTimestamp>(TOptional<char*>, char*)) { Y_UNUSED(valueBuilder); return FromStringFormatImpl(args); } - SIMPLE_UDF(TDateStartOfDay, TDate(TAutoMap<TDate>)) { + SIMPLE_STRICT_UDF(TDateStartOfDay, TDate(TAutoMap<TDate>)) { Y_UNUSED(valueBuilder); const auto input = args[0].Get<ui16>(); return TUnboxedValuePod(ui16(input)); } - SIMPLE_UDF(TDatetimeStartOfDay, TDatetime(TAutoMap<TDatetime>)) { + SIMPLE_STRICT_UDF(TDatetimeStartOfDay, TDatetime(TAutoMap<TDatetime>)) { Y_UNUSED(valueBuilder); const auto input = args[0].Get<ui32>(); return TUnboxedValuePod(ui32(input - input % 86400)); } - SIMPLE_UDF(TTimestampStartOfDay, TTimestamp(TAutoMap<TTimestamp>)) { + SIMPLE_STRICT_UDF(TTimestampStartOfDay, TTimestamp(TAutoMap<TTimestamp>)) { Y_UNUSED(valueBuilder); const auto input = args[0].Get<ui64>(); return TUnboxedValuePod(ui64(input - input % 86400000000ull)); } - SIMPLE_UDF(TGetTimeOfDay, TInterval(TAutoMap<TTimestamp>)) { + SIMPLE_STRICT_UDF(TGetTimeOfDay, TInterval(TAutoMap<TTimestamp>)) { Y_UNUSED(valueBuilder); const auto input = args[0].Get<ui64>(); return TUnboxedValuePod(ui64(input % 86400000000ull)); } #define DATETIME_TO_UDF(unit, type) \ - SIMPLE_UDF(TTo##unit, type(TAutoMap<TTimestamp>)) { \ + SIMPLE_STRICT_UDF(TTo##unit, type(TAutoMap<TTimestamp>)) { \ Y_UNUSED(valueBuilder); \ const ui64 input = args[0].Get<ui64>(); \ TInstant instant = TInstant::MicroSeconds(input); \ @@ -212,7 +212,7 @@ namespace { } #define DATETIME_INTERVAL_TO_UDF(unit, type) \ - SIMPLE_UDF(TIntervalTo##unit, type(TAutoMap<TInterval>)) { \ + SIMPLE_STRICT_UDF(TIntervalTo##unit, type(TAutoMap<TInterval>)) { \ Y_UNUSED(valueBuilder); \ const i64 input = args[0].Get<i64>(); \ TDuration duration = TDuration::MicroSeconds(std::abs(input)); \ @@ -220,58 +220,58 @@ namespace { } #define DATETIME_FROM_UDF(unit) \ - SIMPLE_UDF(TFrom##unit, ui64(TAutoMap<ui64>)) { \ + SIMPLE_STRICT_UDF(TFrom##unit, ui64(TAutoMap<ui64>)) { \ Y_UNUSED(valueBuilder); \ EMPTY_RESULT_ON_EMPTY_ARG(0); \ const auto input = args[0].Get<ui64>(); \ return TUnboxedValuePod(TInstant::unit(input).MicroSeconds()); \ } -#define DATETIME_TIMESTAMP_FROM_UDF(unit) \ - SIMPLE_UDF(TTimestampFrom##unit, TOptional<TTimestamp>(TOptional<ui64>)) { \ - Y_UNUSED(valueBuilder); \ - EMPTY_RESULT_ON_EMPTY_ARG(0); \ - const auto input = args[0].Get<ui64>(); \ - ui64 result = TInstant::unit(input).MicroSeconds(); \ - if (result < MAX_TIMESTAMP) { \ - return TUnboxedValuePod(result); \ - } else { \ - return TUnboxedValuePod(); \ - } \ - } - -#define DATETIME_INTERVAL_FROM_UDF(unit) \ - SIMPLE_UDF(TIntervalFrom##unit, TOptional<TInterval>(TOptional<i64>)) { \ - Y_UNUSED(valueBuilder); \ - EMPTY_RESULT_ON_EMPTY_ARG(0); \ - const auto input = args[0].Get<i64>(); \ - i64 result = TInstant::unit(std::abs(input)).MicroSeconds(); \ - if (static_cast<ui64>(result) < MAX_TIMESTAMP) { \ - return TUnboxedValuePod(input >= 0 ? result : -result); \ - } else { \ - return TUnboxedValuePod(); \ - } \ - } - -#define DATETIME_GET_UDF(udfName, resultType, result) \ - SIMPLE_UDF(udfName, resultType(TAutoMap<TTimestamp>)) { \ - Y_UNUSED(valueBuilder); \ - const auto input = args[0].Get<ui64>(); \ - const TInstant& instant = TInstant::MicroSeconds(input); \ - TSimpleTM tm = TSimpleTM::New( \ - static_cast<time_t>(instant.Seconds())); \ - Y_UNUSED(tm); \ - return TUnboxedValuePod(result); \ - } - -#define DATETIME_GET_STRING_UDF(udfName, result) \ - SIMPLE_UDF(udfName, char*(TAutoMap<TTimestamp>)) { \ - const auto input = args[0].Get<ui64>(); \ - const TInstant& instant = TInstant::MicroSeconds(input); \ - TSimpleTM tm = TSimpleTM::New( \ - static_cast<time_t>(instant.Seconds())); \ - Y_UNUSED(tm); \ - return valueBuilder->NewString(result); \ +#define DATETIME_TIMESTAMP_FROM_UDF(unit) \ + SIMPLE_STRICT_UDF(TTimestampFrom##unit, TOptional<TTimestamp>(TOptional<ui64>)) { \ + Y_UNUSED(valueBuilder); \ + EMPTY_RESULT_ON_EMPTY_ARG(0); \ + const auto input = args[0].Get<ui64>(); \ + ui64 result = TInstant::unit(input).MicroSeconds(); \ + if (result < MAX_TIMESTAMP) { \ + return TUnboxedValuePod(result); \ + } else { \ + return TUnboxedValuePod(); \ + } \ + } + +#define DATETIME_INTERVAL_FROM_UDF(unit) \ + SIMPLE_STRICT_UDF(TIntervalFrom##unit, TOptional<TInterval>(TOptional<i64>)) { \ + Y_UNUSED(valueBuilder); \ + EMPTY_RESULT_ON_EMPTY_ARG(0); \ + const auto input = args[0].Get<i64>(); \ + i64 result = TInstant::unit(std::abs(input)).MicroSeconds(); \ + if (static_cast<ui64>(result) < MAX_TIMESTAMP) { \ + return TUnboxedValuePod(input >= 0 ? result : -result); \ + } else { \ + return TUnboxedValuePod(); \ + } \ + } + +#define DATETIME_GET_UDF(udfName, resultType, result) \ + SIMPLE_STRICT_UDF(udfName, resultType(TAutoMap<TTimestamp>)) { \ + Y_UNUSED(valueBuilder); \ + const auto input = args[0].Get<ui64>(); \ + const TInstant& instant = TInstant::MicroSeconds(input); \ + TSimpleTM tm = TSimpleTM::New( \ + static_cast<time_t>(instant.Seconds())); \ + Y_UNUSED(tm); \ + return TUnboxedValuePod(result); \ + } + +#define DATETIME_GET_STRING_UDF(udfName, result) \ + SIMPLE_STRICT_UDF(udfName, char*(TAutoMap<TTimestamp>)) { \ + const auto input = args[0].Get<ui64>(); \ + const TInstant& instant = TInstant::MicroSeconds(input); \ + TSimpleTM tm = TSimpleTM::New( \ + static_cast<time_t>(instant.Seconds())); \ + Y_UNUSED(tm); \ + return valueBuilder->NewString(result); \ } TInstant InstantFromMicroseconds(ui64 value) { @@ -299,7 +299,7 @@ namespace { } #define DATETIME_START_UDF(udfName, type, logic, inputConv, outputConv) \ - SIMPLE_UDF(udfName, type(TAutoMap<type>)) { \ + SIMPLE_STRICT_UDF(udfName, type(TAutoMap<type>)) { \ Y_UNUSED(valueBuilder); \ const auto input = args[0].Get<typename NUdf::TDataType<type>::TLayout>(); \ TInstant instant = inputConv(input); \ diff --git a/ydb/library/yql/udfs/common/datetime2/CMakeLists.darwin.txt b/ydb/library/yql/udfs/common/datetime2/CMakeLists.darwin.txt index 0eeb6f6caf..eb06e63728 100644 --- a/ydb/library/yql/udfs/common/datetime2/CMakeLists.darwin.txt +++ b/ydb/library/yql/udfs/common/datetime2/CMakeLists.darwin.txt @@ -22,7 +22,7 @@ target_link_libraries(datetime2_udf INTERFACE add_global_library_for(datetime2_udf.global datetime2_udf) target_compile_options(datetime2_udf.global PRIVATE -DUDF_ABI_VERSION_MAJOR=2 - -DUDF_ABI_VERSION_MINOR=27 + -DUDF_ABI_VERSION_MINOR=28 -DUDF_ABI_VERSION_PATCH=0 ) target_link_libraries(datetime2_udf.global PUBLIC diff --git a/ydb/library/yql/udfs/common/datetime2/CMakeLists.linux-aarch64.txt b/ydb/library/yql/udfs/common/datetime2/CMakeLists.linux-aarch64.txt index 047df7b446..11b6578aec 100644 --- a/ydb/library/yql/udfs/common/datetime2/CMakeLists.linux-aarch64.txt +++ b/ydb/library/yql/udfs/common/datetime2/CMakeLists.linux-aarch64.txt @@ -23,7 +23,7 @@ target_link_libraries(datetime2_udf INTERFACE add_global_library_for(datetime2_udf.global datetime2_udf) target_compile_options(datetime2_udf.global PRIVATE -DUDF_ABI_VERSION_MAJOR=2 - -DUDF_ABI_VERSION_MINOR=27 + -DUDF_ABI_VERSION_MINOR=28 -DUDF_ABI_VERSION_PATCH=0 ) target_link_libraries(datetime2_udf.global PUBLIC diff --git a/ydb/library/yql/udfs/common/datetime2/CMakeLists.linux.txt b/ydb/library/yql/udfs/common/datetime2/CMakeLists.linux.txt index 047df7b446..11b6578aec 100644 --- a/ydb/library/yql/udfs/common/datetime2/CMakeLists.linux.txt +++ b/ydb/library/yql/udfs/common/datetime2/CMakeLists.linux.txt @@ -23,7 +23,7 @@ target_link_libraries(datetime2_udf INTERFACE add_global_library_for(datetime2_udf.global datetime2_udf) target_compile_options(datetime2_udf.global PRIVATE -DUDF_ABI_VERSION_MAJOR=2 - -DUDF_ABI_VERSION_MINOR=27 + -DUDF_ABI_VERSION_MINOR=28 -DUDF_ABI_VERSION_PATCH=0 ) target_link_libraries(datetime2_udf.global PUBLIC diff --git a/ydb/library/yql/udfs/common/datetime2/datetime_udf.cpp b/ydb/library/yql/udfs/common/datetime2/datetime_udf.cpp index 731b2f85c9..55c4965332 100644 --- a/ydb/library/yql/udfs/common/datetime2/datetime_udf.cpp +++ b/ydb/library/yql/udfs/common/datetime2/datetime_udf.cpp @@ -309,25 +309,25 @@ NUdf::TUnboxedValuePod DoAddYears(const NUdf::TUnboxedValuePod& date, i64 years, // Make* - SIMPLE_UDF(TMakeDate, TDate(TAutoMap<TResource<TMResourceName>>)) { + SIMPLE_STRICT_UDF(TMakeDate, TDate(TAutoMap<TResource<TMResourceName>>)) { auto& builder = valueBuilder->GetDateBuilder(); auto& storage = Reference(args[0]); return TUnboxedValuePod(storage.ToDate(builder, false)); } - SIMPLE_UDF(TMakeDatetime, TDatetime(TAutoMap<TResource<TMResourceName>>)) { + SIMPLE_STRICT_UDF(TMakeDatetime, TDatetime(TAutoMap<TResource<TMResourceName>>)) { auto& builder = valueBuilder->GetDateBuilder(); auto& storage = Reference(args[0]); return TUnboxedValuePod(storage.ToDatetime(builder)); } - SIMPLE_UDF(TMakeTimestamp, TTimestamp(TAutoMap<TResource<TMResourceName>>)) { + SIMPLE_STRICT_UDF(TMakeTimestamp, TTimestamp(TAutoMap<TResource<TMResourceName>>)) { auto& builder = valueBuilder->GetDateBuilder(); auto& storage = Reference(args[0]); return TUnboxedValuePod(storage.ToTimestamp(builder)); } - SIMPLE_UDF(TMakeTzDate, TTzDate(TAutoMap<TResource<TMResourceName>>)) { + SIMPLE_STRICT_UDF(TMakeTzDate, TTzDate(TAutoMap<TResource<TMResourceName>>)) { auto& builder = valueBuilder->GetDateBuilder(); auto& storage = Reference(args[0]); TUnboxedValuePod result(storage.ToDate(builder, true)); @@ -335,7 +335,7 @@ NUdf::TUnboxedValuePod DoAddYears(const NUdf::TUnboxedValuePod& date, i64 years, return result; } - SIMPLE_UDF(TMakeTzDatetime, TTzDatetime(TAutoMap<TResource<TMResourceName>>)) { + SIMPLE_STRICT_UDF(TMakeTzDatetime, TTzDatetime(TAutoMap<TResource<TMResourceName>>)) { auto& builder = valueBuilder->GetDateBuilder(); auto& storage = Reference(args[0]); TUnboxedValuePod result(storage.ToDatetime(builder)); @@ -343,7 +343,7 @@ NUdf::TUnboxedValuePod DoAddYears(const NUdf::TUnboxedValuePod& date, i64 years, return result; } - SIMPLE_UDF(TMakeTzTimestamp, TTzTimestamp(TAutoMap<TResource<TMResourceName>>)) { + SIMPLE_STRICT_UDF(TMakeTzTimestamp, TTzTimestamp(TAutoMap<TResource<TMResourceName>>)) { auto& builder = valueBuilder->GetDateBuilder(); auto& storage = Reference(args[0]); TUnboxedValuePod result(storage.ToTimestamp(builder)); @@ -353,17 +353,17 @@ NUdf::TUnboxedValuePod DoAddYears(const NUdf::TUnboxedValuePod& date, i64 years, // Get* -#define GET_METHOD(field, type) \ - SIMPLE_UDF(TGet##field, type(TAutoMap<TResource<TMResourceName>>)) { \ - Y_UNUSED(valueBuilder); \ - return TUnboxedValuePod(Get##field(args[0])); \ +#define GET_METHOD(field, type) \ + SIMPLE_STRICT_UDF(TGet##field, type(TAutoMap<TResource<TMResourceName>>)) { \ + Y_UNUSED(valueBuilder); \ + return TUnboxedValuePod(Get##field(args[0])); \ } GET_METHOD(Year, ui16) GET_METHOD(DayOfYear, ui16) GET_METHOD(Month, ui8) - SIMPLE_UDF(TGetMonthName, char*(TAutoMap<TResource<TMResourceName>>)) { + SIMPLE_STRICT_UDF(TGetMonthName, char*(TAutoMap<TResource<TMResourceName>>)) { Y_UNUSED(valueBuilder); static const std::array<TUnboxedValue, 12U> monthNames = {{ TUnboxedValuePod::Embedded(TStringRef::Of("January")), @@ -385,14 +385,14 @@ NUdf::TUnboxedValuePod DoAddYears(const NUdf::TUnboxedValuePod& date, i64 years, GET_METHOD(WeekOfYear, ui8) GET_METHOD(WeekOfYearIso8601, ui8) - SIMPLE_UDF(TGetDayOfMonth, ui8(TAutoMap<TResource<TMResourceName>>)) { + SIMPLE_STRICT_UDF(TGetDayOfMonth, ui8(TAutoMap<TResource<TMResourceName>>)) { Y_UNUSED(valueBuilder); return TUnboxedValuePod(GetDay(args[0])); } GET_METHOD(DayOfWeek, ui8) - SIMPLE_UDF(TGetDayOfWeekName, char*(TAutoMap<TResource<TMResourceName>>)) { + SIMPLE_STRICT_UDF(TGetDayOfWeekName, char*(TAutoMap<TResource<TMResourceName>>)) { Y_UNUSED(valueBuilder); static const std::array<TUnboxedValue, 7U> dayNames = {{ TUnboxedValuePod::Embedded(TStringRef::Of("Monday")), @@ -410,19 +410,19 @@ NUdf::TUnboxedValuePod DoAddYears(const NUdf::TUnboxedValuePod& date, i64 years, GET_METHOD(Minute, ui8) GET_METHOD(Second, ui8) - SIMPLE_UDF(TGetMillisecondOfSecond, ui32(TAutoMap<TResource<TMResourceName>>)) { + SIMPLE_STRICT_UDF(TGetMillisecondOfSecond, ui32(TAutoMap<TResource<TMResourceName>>)) { Y_UNUSED(valueBuilder); return TUnboxedValuePod(GetMicrosecond(args[0]) / 1000u); } - SIMPLE_UDF(TGetMicrosecondOfSecond, ui32(TAutoMap<TResource<TMResourceName>>)) { + SIMPLE_STRICT_UDF(TGetMicrosecondOfSecond, ui32(TAutoMap<TResource<TMResourceName>>)) { Y_UNUSED(valueBuilder); return TUnboxedValuePod(GetMicrosecond(args[0])); } GET_METHOD(TimezoneId, ui16) - SIMPLE_UDF(TGetTimezoneName, char*(TAutoMap<TResource<TMResourceName>>)) { + SIMPLE_STRICT_UDF(TGetTimezoneName, char*(TAutoMap<TResource<TMResourceName>>)) { auto timezoneId = GetTimezoneId(args[0]); if (timezoneId >= NUdf::GetTimezones().size()) { return TUnboxedValuePod(); @@ -549,13 +549,14 @@ NUdf::TUnboxedValuePod DoAddYears(const NUdf::TUnboxedValuePod& date, i64 years, builder.Implementation(new TUpdate(builder.GetSourcePosition())); } + builder.IsStrict(); return true; } }; // From* - SIMPLE_UDF(TFromSeconds, TOptional<TTimestamp>(TAutoMap<ui32>)) { + SIMPLE_STRICT_UDF(TFromSeconds, TOptional<TTimestamp>(TAutoMap<ui32>)) { Y_UNUSED(valueBuilder); auto res = args[0].Get<ui32>(); if (!ValidateDatetime(res)) { @@ -564,7 +565,7 @@ NUdf::TUnboxedValuePod DoAddYears(const NUdf::TUnboxedValuePod& date, i64 years, return TUnboxedValuePod((ui64)(res * 1000000ull)); } - SIMPLE_UDF(TFromMilliseconds, TOptional<TTimestamp>(TAutoMap<ui64>)) { + SIMPLE_STRICT_UDF(TFromMilliseconds, TOptional<TTimestamp>(TAutoMap<ui64>)) { Y_UNUSED(valueBuilder); auto res = args[0].Get<ui64>(); if (res >= MAX_TIMESTAMP / 1000u) { @@ -573,7 +574,7 @@ NUdf::TUnboxedValuePod DoAddYears(const NUdf::TUnboxedValuePod& date, i64 years, return TUnboxedValuePod(res * 1000u); } - SIMPLE_UDF(TFromMicroseconds, TOptional<TTimestamp>(TAutoMap<ui64>)) { + SIMPLE_STRICT_UDF(TFromMicroseconds, TOptional<TTimestamp>(TAutoMap<ui64>)) { Y_UNUSED(valueBuilder); auto res = args[0].Get<ui64>(); if (!ValidateTimestamp(res)) { @@ -582,37 +583,37 @@ NUdf::TUnboxedValuePod DoAddYears(const NUdf::TUnboxedValuePod& date, i64 years, return TUnboxedValuePod(res); } - SIMPLE_UDF(TIntervalFromDays, TOptional<TInterval>(TAutoMap<i32>)) { + SIMPLE_STRICT_UDF(TIntervalFromDays, TOptional<TInterval>(TAutoMap<i32>)) { Y_UNUSED(valueBuilder); const i64 res = i64(args[0].Get<i32>()) * 86400000000ll; return ValidateInterval(res) ? TUnboxedValuePod(res) : TUnboxedValuePod(); } - SIMPLE_UDF(TIntervalFromHours, TOptional<TInterval>(TAutoMap<i32>)) { + SIMPLE_STRICT_UDF(TIntervalFromHours, TOptional<TInterval>(TAutoMap<i32>)) { Y_UNUSED(valueBuilder); const i64 res = i64(args[0].Get<i32>()) * 3600000000ll; return ValidateInterval(res) ? TUnboxedValuePod(res) : TUnboxedValuePod(); } - SIMPLE_UDF(TIntervalFromMinutes, TOptional<TInterval>(TAutoMap<i32>)) { + SIMPLE_STRICT_UDF(TIntervalFromMinutes, TOptional<TInterval>(TAutoMap<i32>)) { Y_UNUSED(valueBuilder); const i64 res = i64(args[0].Get<i32>()) * 60000000ll; return ValidateInterval(res) ? TUnboxedValuePod(res) : TUnboxedValuePod(); } - SIMPLE_UDF(TIntervalFromSeconds, TOptional<TInterval>(TAutoMap<i32>)) { + SIMPLE_STRICT_UDF(TIntervalFromSeconds, TOptional<TInterval>(TAutoMap<i32>)) { Y_UNUSED(valueBuilder); const i64 res = i64(args[0].Get<i32>()) * 1000000ll; return ValidateInterval(res) ? TUnboxedValuePod(res) : TUnboxedValuePod(); } - SIMPLE_UDF(TIntervalFromMilliseconds, TOptional<TInterval>(TAutoMap<i64>)) { + SIMPLE_STRICT_UDF(TIntervalFromMilliseconds, TOptional<TInterval>(TAutoMap<i64>)) { Y_UNUSED(valueBuilder); const i64 res = i64(args[0].Get<i64>()) * 1000ll; return ValidateInterval(res) ? TUnboxedValuePod(res) : TUnboxedValuePod(); } - SIMPLE_UDF(TIntervalFromMicroseconds, TOptional<TInterval>(TAutoMap<i64>)) { + SIMPLE_STRICT_UDF(TIntervalFromMicroseconds, TOptional<TInterval>(TAutoMap<i64>)) { Y_UNUSED(valueBuilder); const i64 res = args[0].Get<i64>(); return ValidateInterval(res) ? TUnboxedValuePod(res) : TUnboxedValuePod(); @@ -620,17 +621,17 @@ NUdf::TUnboxedValuePod DoAddYears(const NUdf::TUnboxedValuePod& date, i64 years, // To* - SIMPLE_UDF(TToDays, i32(TAutoMap<TInterval>)) { + SIMPLE_STRICT_UDF(TToDays, i32(TAutoMap<TInterval>)) { Y_UNUSED(valueBuilder); return TUnboxedValuePod(i32(args[0].Get<i64>() / 86400000000ll)); } - SIMPLE_UDF(TToHours, i32(TAutoMap<TInterval>)) { + SIMPLE_STRICT_UDF(TToHours, i32(TAutoMap<TInterval>)) { Y_UNUSED(valueBuilder); return TUnboxedValuePod(i32(args[0].Get<i64>() / 3600000000ll)); } - SIMPLE_UDF(TToMinutes, i32(TAutoMap<TInterval>)) { + SIMPLE_STRICT_UDF(TToMinutes, i32(TAutoMap<TInterval>)) { Y_UNUSED(valueBuilder); return TUnboxedValuePod(i32(args[0].Get<i64>() / 60000000ll)); } @@ -661,6 +662,7 @@ NUdf::TUnboxedValuePod DoAddYears(const NUdf::TUnboxedValuePod& date, i64 years, if (!typesOnly) { \ builder.Implementation(new TTo##units<TUserDataType>); \ } \ + builder.IsStrict(); \ } \ }; @@ -705,7 +707,7 @@ NUdf::TUnboxedValuePod DoAddYears(const NUdf::TUnboxedValuePod& date, i64 years, // StartOf* - SIMPLE_UDF(TStartOfYear, TOptional<TResource<TMResourceName>>(TAutoMap<TResource<TMResourceName>>)) { + SIMPLE_STRICT_UDF(TStartOfYear, TOptional<TResource<TMResourceName>>(TAutoMap<TResource<TMResourceName>>)) { auto result = args[0]; auto& storage = Reference(result); storage.Month = 1; @@ -722,7 +724,7 @@ NUdf::TUnboxedValuePod DoAddYears(const NUdf::TUnboxedValuePod& date, i64 years, return result; } - SIMPLE_UDF(TStartOfQuarter, TOptional<TResource<TMResourceName>>(TAutoMap<TResource<TMResourceName>>)) { + SIMPLE_STRICT_UDF(TStartOfQuarter, TOptional<TResource<TMResourceName>>(TAutoMap<TResource<TMResourceName>>)) { auto result = args[0]; auto& storage = Reference(result); storage.Month = (storage.Month - 1) / 3 * 3 + 1; @@ -739,7 +741,7 @@ NUdf::TUnboxedValuePod DoAddYears(const NUdf::TUnboxedValuePod& date, i64 years, return result; } - SIMPLE_UDF(TStartOfMonth, TOptional<TResource<TMResourceName>>(TAutoMap<TResource<TMResourceName>>)) { + SIMPLE_STRICT_UDF(TStartOfMonth, TOptional<TResource<TMResourceName>>(TAutoMap<TResource<TMResourceName>>)) { auto result = args[0]; auto& storage = Reference(result); storage.Day = 1; @@ -755,7 +757,7 @@ NUdf::TUnboxedValuePod DoAddYears(const NUdf::TUnboxedValuePod& date, i64 years, return result; } - SIMPLE_UDF(TStartOfWeek, TOptional<TResource<TMResourceName>>(TAutoMap<TResource<TMResourceName>>)) { + SIMPLE_STRICT_UDF(TStartOfWeek, TOptional<TResource<TMResourceName>>(TAutoMap<TResource<TMResourceName>>)) { auto result = args[0]; auto& storage = Reference(result); auto& builder = valueBuilder->GetDateBuilder(); @@ -774,7 +776,7 @@ NUdf::TUnboxedValuePod DoAddYears(const NUdf::TUnboxedValuePod& date, i64 years, return result; } - SIMPLE_UDF(TStartOfDay, TOptional<TResource<TMResourceName>>(TAutoMap<TResource<TMResourceName>>)) { + SIMPLE_STRICT_UDF(TStartOfDay, TOptional<TResource<TMResourceName>>(TAutoMap<TResource<TMResourceName>>)) { auto result = args[0]; auto& storage = Reference(result); storage.Hour = 0; @@ -789,7 +791,7 @@ NUdf::TUnboxedValuePod DoAddYears(const NUdf::TUnboxedValuePod& date, i64 years, return result; } - SIMPLE_UDF(TStartOf, TOptional<TResource<TMResourceName>>(TAutoMap<TResource<TMResourceName>>, TAutoMap<TInterval>)) { + SIMPLE_STRICT_UDF(TStartOf, TOptional<TResource<TMResourceName>>(TAutoMap<TResource<TMResourceName>>, TAutoMap<TInterval>)) { auto result = args[0]; ui64 interval = std::abs(args[1].Get<i64>()); if (interval == 0) { @@ -815,7 +817,7 @@ NUdf::TUnboxedValuePod DoAddYears(const NUdf::TUnboxedValuePod& date, i64 years, return result; } - SIMPLE_UDF(TTimeOfDay, TInterval(TAutoMap<TResource<TMResourceName>>)) { + SIMPLE_STRICT_UDF(TTimeOfDay, TInterval(TAutoMap<TResource<TMResourceName>>)) { Y_UNUSED(valueBuilder); auto& storage = Reference(args[0]); return TUnboxedValuePod((i64)storage.ToTimeOfDay()); @@ -823,15 +825,15 @@ NUdf::TUnboxedValuePod DoAddYears(const NUdf::TUnboxedValuePod& date, i64 years, // Add ... - SIMPLE_UDF(TShiftYears, TOptional<TResource<TMResourceName>>(TAutoMap<TResource<TMResourceName>>, i32)) { + SIMPLE_STRICT_UDF(TShiftYears, TOptional<TResource<TMResourceName>>(TAutoMap<TResource<TMResourceName>>, i32)) { return DoAddYears(args[0], args[1].Get<i32>(), valueBuilder->GetDateBuilder()); } - SIMPLE_UDF(TShiftQuarters, TOptional<TResource<TMResourceName>>(TAutoMap<TResource<TMResourceName>>, i32)) { + SIMPLE_STRICT_UDF(TShiftQuarters, TOptional<TResource<TMResourceName>>(TAutoMap<TResource<TMResourceName>>, i32)) { return DoAddMonths(args[0], 3ll * args[1].Get<i32>(), valueBuilder->GetDateBuilder()); } - SIMPLE_UDF(TShiftMonths, TOptional<TResource<TMResourceName>>(TAutoMap<TResource<TMResourceName>>, i32)) { + SIMPLE_STRICT_UDF(TShiftMonths, TOptional<TResource<TMResourceName>>(TAutoMap<TResource<TMResourceName>>, i32)) { return DoAddMonths(args[0], args[1].Get<i32>(), valueBuilder->GetDateBuilder()); } @@ -1466,18 +1468,18 @@ NUdf::TUnboxedValuePod DoAddYears(const NUdf::TUnboxedValuePod& date, i64 years, } }; -#define PARSE_SPECIFIC_FORMAT(format) \ - SIMPLE_UDF(TParse##format, TOptional<TResource<TMResourceName>>(TAutoMap<char*>)) { \ - auto str = args[0].AsStringRef(); \ - TInstant instant; \ - if (!TInstant::TryParse##format(TStringBuf(str.Data(), str.Size()), instant)) { \ - return TUnboxedValuePod(); \ - } \ - auto& builder = valueBuilder->GetDateBuilder(); \ - TUnboxedValuePod result(0); \ - auto& storage = Reference(result); \ - storage.FromTimestamp(builder, instant.MicroSeconds()); \ - return result; \ +#define PARSE_SPECIFIC_FORMAT(format) \ + SIMPLE_STRICT_UDF(TParse##format, TOptional<TResource<TMResourceName>>(TAutoMap<char*>)) { \ + auto str = args[0].AsStringRef(); \ + TInstant instant; \ + if (!TInstant::TryParse##format(TStringBuf(str.Data(), str.Size()), instant)) { \ + return TUnboxedValuePod(); \ + } \ + auto& builder = valueBuilder->GetDateBuilder(); \ + TUnboxedValuePod result(0); \ + auto& storage = Reference(result); \ + storage.FromTimestamp(builder, instant.MicroSeconds()); \ + return result; \ } PARSE_SPECIFIC_FORMAT(Rfc822); |