diff --git a/velox/functions/prestosql/DateTimeFunctions.h b/velox/functions/prestosql/DateTimeFunctions.h index bb0c173f6cf59..33a891be8f9f2 100644 --- a/velox/functions/prestosql/DateTimeFunctions.h +++ b/velox/functions/prestosql/DateTimeFunctions.h @@ -1779,6 +1779,13 @@ template struct ToISO8601Function { VELOX_DEFINE_FUNCTION_TYPES(T); + ToISO8601Function() { + auto formatter = + functions::buildJodaDateTimeFormatter("yyyy-MM-dd'T'HH:mm:ss.SSSZZ"); + VELOX_CHECK(!formatter.hasError()); + formatter_ = formatter.value(); + } + FOLLY_ALWAYS_INLINE void initialize( const std::vector& inputTypes, const core::QueryConfig& config, @@ -1786,8 +1793,6 @@ struct ToISO8601Function { if (inputTypes[0]->isTimestamp()) { timeZone_ = getTimeZoneFromConfig(config); } - functions::buildJodaDateTimeFormatter("yyyy-MM-dd'T'HH:mm:ss.SSSZZ") - .thenOrThrow([this](auto formatter) { formatter_ = formatter; }); } FOLLY_ALWAYS_INLINE void call(