diff options
author | babichsemyon <babichsemyon@yandex-team.com> | 2023-07-18 17:41:57 +0300 |
---|---|---|
committer | babichsemyon <babichsemyon@yandex-team.com> | 2023-07-18 17:41:57 +0300 |
commit | ef5e7d14434e2f370a1c0919a9a3da49594cf77b (patch) | |
tree | a07a62b8da12a4831d4fef434d2043f9ae5b9e32 | |
parent | bb605c86b04dd75721dddf111e53f5325a82a85b (diff) | |
download | ydb-ef5e7d14434e2f370a1c0919a9a3da49594cf77b.tar.gz |
checking if our datetime is out of bounds
YQL-16117
-rw-r--r-- | ydb/library/yql/udfs/common/datetime2/datetime_udf.cpp | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/ydb/library/yql/udfs/common/datetime2/datetime_udf.cpp b/ydb/library/yql/udfs/common/datetime2/datetime_udf.cpp index 4ad21a52ea6..408ab4f6e9f 100644 --- a/ydb/library/yql/udfs/common/datetime2/datetime_udf.cpp +++ b/ydb/library/yql/udfs/common/datetime2/datetime_udf.cpp @@ -1706,18 +1706,18 @@ NUdf::TUnboxedValuePod DoAddYears(const NUdf::TUnboxedValuePod& date, i64 years, } }; -#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; \ +#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) || instant.Seconds() >= NUdf::MAX_DATETIME) { \ + return TUnboxedValuePod(); \ + } \ + auto& builder = valueBuilder->GetDateBuilder(); \ + TUnboxedValuePod result(0); \ + auto& storage = Reference(result); \ + storage.FromTimestamp(builder, instant.MicroSeconds()); \ + return result; \ } PARSE_SPECIFIC_FORMAT(Rfc822); |