This is an automated email from the ASF dual-hosted git repository. yiguolei pushed a commit to branch branch-2.1 in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-2.1 by this push: new 309de6c82b1 [fix](smooth-upgrade) Fix function now upgrade compatible #32807 309de6c82b1 is described below commit 309de6c82b110ba92a5af387f12f7ae9cbf8f755 Author: zclllyybb <zhaochan...@selectdb.com> AuthorDate: Wed Mar 27 10:48:52 2024 +0800 [fix](smooth-upgrade) Fix function now upgrade compatible #32807 --- be/src/agent/be_exec_version_manager.h | 1 + .../function_date_or_datetime_computation.cpp | 5 ++++ .../function_date_or_datetime_computation.h | 35 ++++++++++++++++++++++ be/src/vec/functions/simple_function_factory.h | 2 +- 4 files changed, 42 insertions(+), 1 deletion(-) diff --git a/be/src/agent/be_exec_version_manager.h b/be/src/agent/be_exec_version_manager.h index 470d78ee981..32a520cc4bd 100644 --- a/be/src/agent/be_exec_version_manager.h +++ b/be/src/agent/be_exec_version_manager.h @@ -69,6 +69,7 @@ private: * e. change shuffle serialize/deserialize way * f. shrink some function's nullable mode. * g. do local merge of remote runtime filter + * h. "now": ALWAYS_NOT_NULLABLE -> DEPEND_ON_ARGUMENTS */ constexpr inline int BeExecVersionManager::max_be_exec_version = 4; constexpr inline int BeExecVersionManager::min_be_exec_version = 0; diff --git a/be/src/vec/functions/function_date_or_datetime_computation.cpp b/be/src/vec/functions/function_date_or_datetime_computation.cpp index 8fdfad86465..6ec5db65889 100644 --- a/be/src/vec/functions/function_date_or_datetime_computation.cpp +++ b/be/src/vec/functions/function_date_or_datetime_computation.cpp @@ -97,6 +97,9 @@ using FunctionLocalTimeWithPrecision = using FunctionLocalTimestampWithPrecision = FunctionCurrentDateOrDateTime<CurrentDateTimeImpl<LocalTimestampFunctionName, true>>; +using FunctionNowWithPrecisionOld = + FunctionCurrentDateOrDateTimeOld<CurrentDateTimeImpl<NowFunctionName, true>>; + struct CurDateFunctionName { static constexpr auto name = "curdate"; }; @@ -182,6 +185,8 @@ void register_function_date_time_computation(SimpleFunctionFactory& factory) { factory.register_function<FunctionMilliSecToDateTime>(); factory.register_function<FunctionSecToDateTime>(); + factory.register_alternative_function<FunctionNowWithPrecisionOld>(); + // alias factory.register_alias("days_add", "date_add"); factory.register_alias("days_add", "adddate"); diff --git a/be/src/vec/functions/function_date_or_datetime_computation.h b/be/src/vec/functions/function_date_or_datetime_computation.h index 383fb10e34a..dc119821beb 100644 --- a/be/src/vec/functions/function_date_or_datetime_computation.h +++ b/be/src/vec/functions/function_date_or_datetime_computation.h @@ -993,6 +993,41 @@ struct CurrentDateTimeImpl { } }; +template <typename FunctionImpl> +class FunctionCurrentDateOrDateTimeOld : public IFunction { +public: + static constexpr bool has_variadic_argument = + !std::is_void_v<decltype(has_variadic_argument_types(std::declval<FunctionImpl>()))>; + + static constexpr auto name = FunctionImpl::name; + static FunctionPtr create() { return std::make_shared<FunctionCurrentDateOrDateTimeOld>(); } + + String get_name() const override { return name; } + + size_t get_number_of_arguments() const override { return 0; } + + // the only diff in old version is it's ALWAYS_NOT_NULLABLE + bool use_default_implementation_for_nulls() const override { return false; } + + DataTypePtr get_return_type_impl(const ColumnsWithTypeAndName& arguments) const override { + return std::make_shared<typename FunctionImpl::ReturnType>(); + } + + bool is_variadic() const override { return true; } + + DataTypes get_variadic_argument_types_impl() const override { + if constexpr (has_variadic_argument) { + return FunctionImpl::get_variadic_argument_types(); + } + return {}; + } + + Status execute_impl(FunctionContext* context, Block& block, const ColumnNumbers& arguments, + size_t result, size_t input_rows_count) const override { + return FunctionImpl::execute(context, block, arguments, result, input_rows_count); + } +}; + template <typename FunctionName, typename DateType, typename NativeType> struct CurrentDateImpl { using ReturnType = DateType; diff --git a/be/src/vec/functions/simple_function_factory.h b/be/src/vec/functions/simple_function_factory.h index e71bab4b582..a18b0beb8db 100644 --- a/be/src/vec/functions/simple_function_factory.h +++ b/be/src/vec/functions/simple_function_factory.h @@ -151,7 +151,7 @@ public: /// @TEMPORARY: for be_exec_version=3 template <class Function> void register_alternative_function() { - static std::string suffix {"_old_for_version_before_3_0"}; + static std::string suffix {"_old_for_version_before_4_0"}; function_to_replace[Function::name] = Function::name + suffix; register_function(Function::name + suffix, &createDefaultFunction<Function>); } --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org