aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbabichsemyon <babichsemyon@yandex-team.com>2023-07-18 17:41:57 +0300
committerbabichsemyon <babichsemyon@yandex-team.com>2023-07-18 17:41:57 +0300
commitef5e7d14434e2f370a1c0919a9a3da49594cf77b (patch)
treea07a62b8da12a4831d4fef434d2043f9ae5b9e32
parentbb605c86b04dd75721dddf111e53f5325a82a85b (diff)
downloadydb-ef5e7d14434e2f370a1c0919a9a3da49594cf77b.tar.gz
checking if our datetime is out of bounds
YQL-16117
-rw-r--r--ydb/library/yql/udfs/common/datetime2/datetime_udf.cpp24
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);