diff --git a/be/src/agent/be_exec_version_manager.h b/be/src/agent/be_exec_version_manager.h index f3e7a1c38c8d556..23c692bb86212c1 100644 --- a/be/src/agent/be_exec_version_manager.h +++ b/be/src/agent/be_exec_version_manager.h @@ -46,12 +46,16 @@ class BeExecVersionManager { static const int min_be_exec_version; }; -// When we have some breaking change for execute engine, we should update be_exec_version. -// 0: not contain be_exec_version. -// 1: start from doris 1.2 -// a. remove ColumnString terminating zero. -// b. runtime filter use new hash method. -inline const int BeExecVersionManager::max_be_exec_version = 1; +/* + * When we have some breaking change for execute engine, we should update be_exec_version. + * 0: not contain be_exec_version. + * 1: start from doris 1.2 + * a. remove ColumnString terminating zero. + * b. runtime filter use new hash method. + * 2: start from doris 2.0 + * a. function month/day/hour/minute/second's return type is changed to smaller type. +*/ +inline const int BeExecVersionManager::max_be_exec_version = 2; inline const int BeExecVersionManager::min_be_exec_version = 0; } // namespace doris diff --git a/be/src/olap/schema_change.cpp b/be/src/olap/schema_change.cpp index d96a103f2da82ec..2089b7c62dee4f0 100644 --- a/be/src/olap/schema_change.cpp +++ b/be/src/olap/schema_change.cpp @@ -225,6 +225,7 @@ Status BlockChanger::change_block(vectorized::Block* ref_block, ObjectPool pool; RuntimeState* state = pool.add(new RuntimeState()); state->set_desc_tbl(&_desc_tbl); + state->set_be_exec_version(_fe_compatible_version); RowDescriptor row_desc = RowDescriptor(_desc_tbl.get_tuple_descriptor(_desc_tbl.get_row_tuples()[0]), false); @@ -1087,6 +1088,7 @@ Status SchemaChangeHandler::_do_process_alter_tablet_v2(const TAlterTabletReqV2& sc_params.ref_rowset_readers = rs_readers; sc_params.delete_handler = &delete_handler; sc_params.base_tablet_schema = base_tablet_schema; + sc_params.be_exec_version = request.be_exec_version; DCHECK(request.__isset.alter_tablet_type); switch (request.alter_tablet_type) { case TAlterTabletType::SCHEMA_CHANGE: @@ -1651,6 +1653,7 @@ Status SchemaChangeHandler::_parse_request(const SchemaChangeParams& sc_params, BlockChanger* changer, bool* sc_sorting, bool* sc_directly) { changer->set_type(sc_params.alter_tablet_type); + changer->set_compatible_version(sc_params.be_exec_version); TabletSharedPtr base_tablet = sc_params.base_tablet; TabletSharedPtr new_tablet = sc_params.new_tablet; diff --git a/be/src/olap/schema_change.h b/be/src/olap/schema_change.h index 067e74e341f5104..16226dfead353b1 100644 --- a/be/src/olap/schema_change.h +++ b/be/src/olap/schema_change.h @@ -17,6 +17,8 @@ #pragma once +#include + #include "common/status.h" #include "gen_cpp/AgentService_types.h" #include "olap/column_mapping.h" @@ -48,6 +50,8 @@ class BlockChanger { void set_type(AlterTabletType type) { _type = type; } + void set_compatible_version(int32_t version) noexcept { _fe_compatible_version = version; } + bool has_where() const { return _where_expr != nullptr; } private: @@ -62,6 +66,8 @@ class BlockChanger { std::shared_ptr _where_expr; AlterTabletType _type; + + int32_t _fe_compatible_version = -1; }; class SchemaChange { @@ -263,6 +269,7 @@ class SchemaChangeHandler { std::unordered_map materialized_params_map; DescriptorTbl* desc_tbl = nullptr; ObjectPool pool; + int32_t be_exec_version; }; static Status _do_process_alter_tablet_v2(const TAlterTabletReqV2& request); diff --git a/be/src/runtime/runtime_state.h b/be/src/runtime/runtime_state.h index 70e771c5c371a77..ae98d7e68a84f1b 100644 --- a/be/src/runtime/runtime_state.h +++ b/be/src/runtime/runtime_state.h @@ -372,6 +372,8 @@ class RuntimeState { return 0; } + void set_be_exec_version(int32_t version) noexcept { _query_options.be_exec_version = version; } + private: Status create_error_log_file(); diff --git a/be/src/vec/exprs/vectorized_fn_call.cpp b/be/src/vec/exprs/vectorized_fn_call.cpp index 761797b7620a505..af551b7dcc86dd2 100644 --- a/be/src/vec/exprs/vectorized_fn_call.cpp +++ b/be/src/vec/exprs/vectorized_fn_call.cpp @@ -55,8 +55,9 @@ doris::Status VectorizedFnCall::prepare(doris::RuntimeState* state, "and restart be."); } } else { - _function = SimpleFunctionFactory::instance().get_function(_fn.name.function_name, - argument_template, _data_type); + // get the function. won't prepare function. + _function = SimpleFunctionFactory::instance().get_function( + _fn.name.function_name, argument_template, _data_type, state->be_exec_version()); } if (_function == nullptr) { std::string type_str; diff --git a/be/src/vec/functions/function.h b/be/src/vec/functions/function.h index a5f51231787f9d2..94decc1a8ee7850 100644 --- a/be/src/vec/functions/function.h +++ b/be/src/vec/functions/function.h @@ -300,11 +300,14 @@ class IFunctionBuilder { using FunctionBuilderPtr = std::shared_ptr; +/// used in function_factory. when we register a function, save a builder. to get a function, to get a builder. +/// will use DefaultFunctionBuilder as the default builder in function's registration if we didn't explicitly specify. class FunctionBuilderImpl : public IFunctionBuilder { public: FunctionBasePtr build(const ColumnsWithTypeAndName& arguments, const DataTypePtr& return_type) const final { const DataTypePtr& func_return_type = get_return_type(arguments); + // check return types equal. DCHECK(return_type->equals(*func_return_type) || // For null constant argument, `get_return_type` would return // Nullable when `use_default_implementation_for_nulls` is true. @@ -371,6 +374,7 @@ class FunctionBuilderImpl : public IFunctionBuilder { /// If it isn't, will convert all ColumnLowCardinality arguments to full columns. virtual bool can_be_executed_on_low_cardinality_dictionary() const { return true; } + /// return a real function object to execute. called in build(...). virtual FunctionBasePtr build_impl(const ColumnsWithTypeAndName& arguments, const DataTypePtr& return_type) const = 0; @@ -449,7 +453,7 @@ class IFunction : public std::enable_shared_from_this, } }; -/// Wrappers over IFunction. +/// Wrappers over IFunction. If we (default)use DefaultFunction as wrapper, all function execution will go through this. class DefaultExecutable final : public PreparedFunctionImpl { public: @@ -485,6 +489,10 @@ class DefaultExecutable final : public PreparedFunctionImpl { std::shared_ptr function; }; +/* + * when we register a function which didn't specify its base(i.e. inherited from IFunction), actually we use this as a wrapper. + * it saves real implementation as `function`. +*/ class DefaultFunction final : public IFunctionBase { public: DefaultFunction(std::shared_ptr function_, DataTypes arguments_, @@ -498,6 +506,7 @@ class DefaultFunction final : public IFunctionBase { const DataTypes& get_argument_types() const override { return arguments; } const DataTypePtr& get_return_type() const override { return return_type; } + // return a default wrapper for IFunction. PreparedFunctionPtr prepare(FunctionContext* context, const Block& /*sample_block*/, const ColumnNumbers& /*arguments*/, size_t /*result*/) const override { @@ -599,7 +608,9 @@ class DefaultFunctionBuilder : public FunctionBuilderImpl { FunctionBasePtr build_impl(const ColumnsWithTypeAndName& arguments, const DataTypePtr& return_type) const override { DataTypes data_types(arguments.size()); - for (size_t i = 0; i < arguments.size(); ++i) data_types[i] = arguments[i].type; + for (size_t i = 0; i < arguments.size(); ++i) { + data_types[i] = arguments[i].type; + } return std::make_shared(function, data_types, return_type); } 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 990c6da187cb271..1f2de986a1edc8c 100644 --- a/be/src/vec/functions/function_date_or_datetime_computation.cpp +++ b/be/src/vec/functions/function_date_or_datetime_computation.cpp @@ -124,6 +124,10 @@ using FunctionCurrentTime = FunctionCurrentDateOrDateTime; using FunctionTimeToSec = FunctionCurrentDateOrDateTime; +/// @TEMPORARY: for be_exec_version=2 +using FunctionToWeekTwoArgsOld = + FunctionDateOrDateTimeComputation>; + void register_function_date_time_computation(SimpleFunctionFactory& factory) { factory.register_function(); factory.register_function(); @@ -178,6 +182,8 @@ void register_function_date_time_computation(SimpleFunctionFactory& factory) { factory.register_alias("days_add", "date_add"); factory.register_alias("days_add", "adddate"); factory.register_alias("months_add", "add_months"); + /// @TEMPORARY: for be_exec_version=2 + factory.register_alternative_function(); } } // namespace doris::vectorized 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 f84f16c7257e46b..9aaaa217084ae71 100644 --- a/be/src/vec/functions/function_date_or_datetime_computation.h +++ b/be/src/vec/functions/function_date_or_datetime_computation.h @@ -270,7 +270,7 @@ TIME_DIFF_FUNCTION_IMPL(HoursDiffImpl, hours_diff, HOUR); TIME_DIFF_FUNCTION_IMPL(MintueSDiffImpl, minutes_diff, MINUTE); TIME_DIFF_FUNCTION_IMPL(SecondsDiffImpl, seconds_diff, SECOND); -#define TIME_FUNCTION_TWO_ARGS_IMPL(CLASS, NAME, FUNCTION) \ +#define TIME_FUNCTION_TWO_ARGS_IMPL(CLASS, NAME, FUNCTION, RETURN_TYPE) \ template \ struct CLASS { \ using ArgType = std::conditional_t< \ @@ -280,7 +280,7 @@ TIME_DIFF_FUNCTION_IMPL(SecondsDiffImpl, seconds_diff, SECOND); std::is_same_v, DateV2Value, \ std::conditional_t, \ DateV2Value, VecDateTimeValue>>; \ - using ReturnType = DataTypeInt32; \ + using ReturnType = RETURN_TYPE; \ static constexpr auto name = #NAME; \ static constexpr auto is_nullable = false; \ static inline ReturnType::FieldType execute(const ArgType& t0, const Int32 mode, \ @@ -294,8 +294,11 @@ TIME_DIFF_FUNCTION_IMPL(SecondsDiffImpl, seconds_diff, SECOND); } \ } -TIME_FUNCTION_TWO_ARGS_IMPL(ToYearWeekTwoArgsImpl, yearweek, year_week(mysql_week_mode(mode))); -TIME_FUNCTION_TWO_ARGS_IMPL(ToWeekTwoArgsImpl, week, week(mysql_week_mode(mode))); +TIME_FUNCTION_TWO_ARGS_IMPL(ToYearWeekTwoArgsImpl, yearweek, year_week(mysql_week_mode(mode)), + DataTypeInt32); +TIME_FUNCTION_TWO_ARGS_IMPL(ToWeekTwoArgsImpl, week, week(mysql_week_mode(mode)), DataTypeInt8); +/// @TEMPORARY: for be_exec_version=2 +TIME_FUNCTION_TWO_ARGS_IMPL(ToWeekTwoArgsImplOld, week, week(mysql_week_mode(mode)), DataTypeInt32); template struct DateTimeOp { diff --git a/be/src/vec/functions/function_date_or_datetime_computation_v2.cpp b/be/src/vec/functions/function_date_or_datetime_computation_v2.cpp index af7db77a9b9984c..f3984be2b40b929 100644 --- a/be/src/vec/functions/function_date_or_datetime_computation_v2.cpp +++ b/be/src/vec/functions/function_date_or_datetime_computation_v2.cpp @@ -106,6 +106,10 @@ using FunctionDatetimeV2ToYearWeekTwoArgs = using FunctionDatetimeV2ToWeekTwoArgs = FunctionDateOrDateTimeComputation>; +/// @TEMPORARY: for be_exec_version=2 +using FunctionDatetimeV2ToWeekTwoArgsOld = + FunctionDateOrDateTimeComputation>; + void register_function_date_time_computation_v2(SimpleFunctionFactory& factory) { factory.register_function(); factory.register_function(); @@ -168,6 +172,9 @@ void register_function_date_time_computation_v2(SimpleFunctionFactory& factory) factory.register_function(); factory.register_function(); factory.register_function(); + + /// @TEMPORARY: for be_exec_version=2 + factory.register_alternative_function(); } } // namespace doris::vectorized diff --git a/be/src/vec/functions/function_date_or_datetime_to_something.h b/be/src/vec/functions/function_date_or_datetime_to_something.h index 5d41c2349f1beec..b5c8078b01f0ff9 100644 --- a/be/src/vec/functions/function_date_or_datetime_to_something.h +++ b/be/src/vec/functions/function_date_or_datetime_to_something.h @@ -41,7 +41,9 @@ class FunctionDateOrDateTimeToSomething : public IFunction { bool is_variadic() const override { return true; } size_t get_number_of_arguments() const override { return 0; } DataTypes get_variadic_argument_types_impl() const override { - if constexpr (has_variadic_argument) return Transform::get_variadic_argument_types(); + if constexpr (has_variadic_argument) { + return Transform::get_variadic_argument_types(); + } return {}; } diff --git a/be/src/vec/functions/simple_function_factory.h b/be/src/vec/functions/simple_function_factory.h index dcd20fdc876393d..c38534d943c0625 100644 --- a/be/src/vec/functions/simple_function_factory.h +++ b/be/src/vec/functions/simple_function_factory.h @@ -23,6 +23,8 @@ #include #include +#include "agent/be_exec_version_manager.h" +#include "udf/udf.h" #include "vec/exprs/table_function/table_function.h" #include "vec/functions/function.h" @@ -99,6 +101,8 @@ class SimpleFunctionFactory { using Creator = std::function; using FunctionCreators = phmap::flat_hash_map; using FunctionIsVariadic = phmap::flat_hash_set; + /// @TEMPORARY: for be_exec_version=2 + constexpr static int DATETIME_FUNCTION_NEW = 2; public: void register_function(const std::string& name, const Creator& ptr) { @@ -135,14 +139,25 @@ class SimpleFunctionFactory { function_alias[alias] = name; } + /// @TEMPORARY: for be_exec_version=2 + template + void register_alternative_function() { + static std::string suffix {"_old_for_version_before_2_0"}; + function_to_replace[Function::name] = Function::name + suffix; + register_function(Function::name + suffix, &createDefaultFunction); + } + FunctionBasePtr get_function(const std::string& name, const ColumnsWithTypeAndName& arguments, - const DataTypePtr& return_type) { + const DataTypePtr& return_type, + int be_version = BeExecVersionManager::get_newest_version()) { std::string key_str = name; if (function_alias.count(name)) { key_str = function_alias[name]; } + temporary_function_update(be_version, key_str); + // if function is variadic, added types_str as key if (function_variadic_set.count(key_str)) { for (auto& arg : arguments) { @@ -155,24 +170,35 @@ class SimpleFunctionFactory { } auto iter = function_creators.find(key_str); - if (iter != function_creators.end()) { - return iter->second()->build(arguments, return_type); + if (iter == function_creators.end()) { + LOG(WARNING) << fmt::format("Function signature {} is not found", key_str); + return nullptr; } - LOG(WARNING) << fmt::format("Function signature {} is not found", key_str); - return nullptr; + return iter->second()->build(arguments, return_type); } private: FunctionCreators function_creators; FunctionIsVariadic function_variadic_set; std::unordered_map function_alias; + /// @TEMPORARY: for be_exec_version=2. replace function to old version. + std::unordered_map function_to_replace; template static FunctionBuilderPtr createDefaultFunction() { return std::make_shared(Function::create()); } + /// @TEMPORARY: for be_exec_version=2 + void temporary_function_update(int fe_version_now, std::string& name) { + // replace if fe is old version. + if (fe_version_now < DATETIME_FUNCTION_NEW && + function_to_replace.find(name) != function_to_replace.end()) { + name = function_to_replace[name]; + } + } + public: static SimpleFunctionFactory& instance() { static std::once_flag oc; diff --git a/be/src/vec/functions/time_of_function.cpp b/be/src/vec/functions/time_of_function.cpp index e2e4b2962524093..415e8030c6bc027 100644 --- a/be/src/vec/functions/time_of_function.cpp +++ b/be/src/vec/functions/time_of_function.cpp @@ -22,34 +22,62 @@ namespace doris::vectorized { -using FunctionWeekOfYear = FunctionDateOrDateTimeToSomething>; +using FunctionWeekOfYear = FunctionDateOrDateTimeToSomething>; using FunctionWeekOfYearV2 = - FunctionDateOrDateTimeToSomething>; -using FunctionDayOfYear = FunctionDateOrDateTimeToSomething>; -using FunctionDayOfYearV2 = FunctionDateOrDateTimeToSomething>; -using FunctionDayOfWeek = FunctionDateOrDateTimeToSomething>; -using FunctionDayOfWeekV2 = FunctionDateOrDateTimeToSomething>; -using FunctionDayOfMonth = FunctionDateOrDateTimeToSomething>; + FunctionDateOrDateTimeToSomething>; +using FunctionDayOfYear = FunctionDateOrDateTimeToSomething>; +using FunctionDayOfYearV2 = FunctionDateOrDateTimeToSomething>; +using FunctionDayOfWeek = FunctionDateOrDateTimeToSomething>; +using FunctionDayOfWeekV2 = FunctionDateOrDateTimeToSomething>; +using FunctionDayOfMonth = FunctionDateOrDateTimeToSomething>; using FunctionDayOfMonthV2 = - FunctionDateOrDateTimeToSomething>; + FunctionDateOrDateTimeToSomething>; using FunctionYearWeek = FunctionDateOrDateTimeToSomething>; using FunctionYearWeekV2 = FunctionDateOrDateTimeToSomething>; -using FunctionWeekDay = FunctionDateOrDateTimeToSomething>; -using FunctionWeekDayV2 = FunctionDateOrDateTimeToSomething>; +using FunctionWeekDay = FunctionDateOrDateTimeToSomething>; +using FunctionWeekDayV2 = FunctionDateOrDateTimeToSomething>; using FunctionDateTimeV2WeekOfYear = - FunctionDateOrDateTimeToSomething>; + FunctionDateOrDateTimeToSomething>; using FunctionDateTimeV2DayOfYear = - FunctionDateOrDateTimeToSomething>; + FunctionDateOrDateTimeToSomething>; using FunctionDateTimeV2DayOfWeek = - FunctionDateOrDateTimeToSomething>; + FunctionDateOrDateTimeToSomething>; using FunctionDateTimeV2DayOfMonth = - FunctionDateOrDateTimeToSomething>; + FunctionDateOrDateTimeToSomething>; using FunctionDateTimeV2YearWeek = FunctionDateOrDateTimeToSomething>; using FunctionDateTimeV2WeekDay = + FunctionDateOrDateTimeToSomething>; + +/// @TEMPORARY: for be_exec_version=2 +using FunctionWeekOfYearOld = + FunctionDateOrDateTimeToSomething>; +using FunctionWeekOfYearV2Old = + FunctionDateOrDateTimeToSomething>; +using FunctionDayOfYearOld = FunctionDateOrDateTimeToSomething>; +using FunctionDayOfYearV2Old = + FunctionDateOrDateTimeToSomething>; +using FunctionDayOfWeekOld = FunctionDateOrDateTimeToSomething>; +using FunctionDayOfWeekV2Old = + FunctionDateOrDateTimeToSomething>; +using FunctionDayOfMonthOld = + FunctionDateOrDateTimeToSomething>; +using FunctionDayOfMonthV2Old = + FunctionDateOrDateTimeToSomething>; +using FunctionWeekDayOld = FunctionDateOrDateTimeToSomething>; +using FunctionWeekDayV2Old = FunctionDateOrDateTimeToSomething>; +using FunctionDateTimeV2WeekOfYearOld = + FunctionDateOrDateTimeToSomething>; +using FunctionDateTimeV2DayOfYearOld = + FunctionDateOrDateTimeToSomething>; +using FunctionDateTimeV2DayOfWeekOld = + FunctionDateOrDateTimeToSomething>; +using FunctionDateTimeV2DayOfMonthOld = + FunctionDateOrDateTimeToSomething>; +using FunctionDateTimeV2WeekDayOld = FunctionDateOrDateTimeToSomething>; void register_function_time_of_function(SimpleFunctionFactory& factory) { @@ -71,5 +99,22 @@ void register_function_time_of_function(SimpleFunctionFactory& factory) { factory.register_function(); factory.register_function(); factory.register_function(); + + /// @TEMPORARY: for be_exec_version=2 + factory.register_alternative_function(); + factory.register_alternative_function(); + factory.register_alternative_function(); + factory.register_alternative_function(); + factory.register_alternative_function(); + factory.register_alternative_function(); + factory.register_alternative_function(); + factory.register_alternative_function(); + factory.register_alternative_function(); + factory.register_alternative_function(); + factory.register_alternative_function(); + factory.register_alternative_function(); + factory.register_alternative_function(); + factory.register_alternative_function(); + factory.register_alternative_function(); } } // namespace doris::vectorized \ No newline at end of file diff --git a/be/src/vec/functions/to_time_function.cpp b/be/src/vec/functions/to_time_function.cpp index f718f68b0f61846..01130e123f8e25e 100644 --- a/be/src/vec/functions/to_time_function.cpp +++ b/be/src/vec/functions/to_time_function.cpp @@ -23,22 +23,22 @@ namespace doris::vectorized { -using FunctionYear = FunctionDateOrDateTimeToSomething>; -using FunctionYearV2 = FunctionDateOrDateTimeToSomething>; -using FunctionQuarter = FunctionDateOrDateTimeToSomething>; -using FunctionQuarterV2 = FunctionDateOrDateTimeToSomething>; -using FunctionMonth = FunctionDateOrDateTimeToSomething>; -using FunctionMonthV2 = FunctionDateOrDateTimeToSomething>; -using FunctionDay = FunctionDateOrDateTimeToSomething>; -using FunctionDayV2 = FunctionDateOrDateTimeToSomething>; -using FunctionWeek = FunctionDateOrDateTimeToSomething>; -using FunctionWeekV2 = FunctionDateOrDateTimeToSomething>; -using FunctionHour = FunctionDateOrDateTimeToSomething>; -using FunctionHourV2 = FunctionDateOrDateTimeToSomething>; -using FunctionMinute = FunctionDateOrDateTimeToSomething>; -using FunctionMinuteV2 = FunctionDateOrDateTimeToSomething>; -using FunctionSecond = FunctionDateOrDateTimeToSomething>; -using FunctionSecondV2 = FunctionDateOrDateTimeToSomething>; +using FunctionYear = FunctionDateOrDateTimeToSomething>; +using FunctionYearV2 = FunctionDateOrDateTimeToSomething>; +using FunctionQuarter = FunctionDateOrDateTimeToSomething>; +using FunctionQuarterV2 = FunctionDateOrDateTimeToSomething>; +using FunctionMonth = FunctionDateOrDateTimeToSomething>; +using FunctionMonthV2 = FunctionDateOrDateTimeToSomething>; +using FunctionDay = FunctionDateOrDateTimeToSomething>; +using FunctionDayV2 = FunctionDateOrDateTimeToSomething>; +using FunctionWeek = FunctionDateOrDateTimeToSomething>; +using FunctionWeekV2 = FunctionDateOrDateTimeToSomething>; +using FunctionHour = FunctionDateOrDateTimeToSomething>; +using FunctionHourV2 = FunctionDateOrDateTimeToSomething>; +using FunctionMinute = FunctionDateOrDateTimeToSomething>; +using FunctionMinuteV2 = FunctionDateOrDateTimeToSomething>; +using FunctionSecond = FunctionDateOrDateTimeToSomething>; +using FunctionSecondV2 = FunctionDateOrDateTimeToSomething>; using FunctionToDays = FunctionDateOrDateTimeToSomething>; using FunctionToDaysV2 = FunctionDateOrDateTimeToSomething>; using FunctionToDate = FunctionDateOrDateTimeToSomething>; @@ -46,19 +46,19 @@ using FunctionToDateV2 = FunctionDateOrDateTimeToSomething>; using FunctionDateV2 = FunctionDateOrDateTimeToSomething>; -using FunctionDateTimeV2Year = FunctionDateOrDateTimeToSomething>; +using FunctionDateTimeV2Year = FunctionDateOrDateTimeToSomething>; using FunctionDateTimeV2Quarter = - FunctionDateOrDateTimeToSomething>; + FunctionDateOrDateTimeToSomething>; using FunctionDateTimeV2Month = - FunctionDateOrDateTimeToSomething>; -using FunctionDateTimeV2Day = FunctionDateOrDateTimeToSomething>; + FunctionDateOrDateTimeToSomething>; +using FunctionDateTimeV2Day = FunctionDateOrDateTimeToSomething>; using FunctionDateTimeV2Week = - FunctionDateOrDateTimeToSomething>; -using FunctionDateTimeV2Hour = FunctionDateOrDateTimeToSomething>; + FunctionDateOrDateTimeToSomething>; +using FunctionDateTimeV2Hour = FunctionDateOrDateTimeToSomething>; using FunctionDateTimeV2Minute = - FunctionDateOrDateTimeToSomething>; + FunctionDateOrDateTimeToSomething>; using FunctionDateTimeV2Second = - FunctionDateOrDateTimeToSomething>; + FunctionDateOrDateTimeToSomething>; using FunctionDateTimeV2ToDays = FunctionDateOrDateTimeToSomething>; using FunctionDateTimeV2ToDate = @@ -69,6 +69,42 @@ using FunctionTimeStamp = FunctionDateOrDateTimeToSomething>; +/// @TEMPORARY: for be_exec_version=2 +using FunctionYearOld = FunctionDateOrDateTimeToSomething>; +using FunctionYearV2Old = FunctionDateOrDateTimeToSomething>; +using FunctionQuarterOld = FunctionDateOrDateTimeToSomething>; +using FunctionQuarterV2Old = + FunctionDateOrDateTimeToSomething>; +using FunctionMonthOld = FunctionDateOrDateTimeToSomething>; +using FunctionMonthV2Old = FunctionDateOrDateTimeToSomething>; +using FunctionWeekOld = FunctionDateOrDateTimeToSomething>; +using FunctionWeekV2Old = + FunctionDateOrDateTimeToSomething>; +using FunctionDayOld = FunctionDateOrDateTimeToSomething>; +using FunctionDayV2Old = FunctionDateOrDateTimeToSomething>; +using FunctionHourOld = FunctionDateOrDateTimeToSomething>; +using FunctionHourV2Old = FunctionDateOrDateTimeToSomething>; +using FunctionMinuteOld = FunctionDateOrDateTimeToSomething>; +using FunctionMinuteV2Old = FunctionDateOrDateTimeToSomething>; +using FunctionSecondOld = FunctionDateOrDateTimeToSomething>; +using FunctionSecondV2Old = FunctionDateOrDateTimeToSomething>; +using FunctionDateTimeV2YearOld = + FunctionDateOrDateTimeToSomething>; +using FunctionDateTimeV2QuarterOld = + FunctionDateOrDateTimeToSomething>; +using FunctionDateTimeV2MonthOld = + FunctionDateOrDateTimeToSomething>; +using FunctionDateTimeV2WeekOld = + FunctionDateOrDateTimeToSomething>; +using FunctionDateTimeV2DayOld = + FunctionDateOrDateTimeToSomething>; +using FunctionDateTimeV2HourOld = + FunctionDateOrDateTimeToSomething>; +using FunctionDateTimeV2MinuteOld = + FunctionDateOrDateTimeToSomething>; +using FunctionDateTimeV2SecondOld = + FunctionDateOrDateTimeToSomething>; + void register_function_to_time_function(SimpleFunctionFactory& factory) { factory.register_function(); factory.register_function(); @@ -107,6 +143,32 @@ void register_function_to_time_function(SimpleFunctionFactory& factory) { factory.register_function(); factory.register_alias("date", "datev2"); factory.register_alias("to_date", "to_datev2"); + + /// @TEMPORARY: for be_exec_version=2 + factory.register_alternative_function(); + factory.register_alternative_function(); + factory.register_alternative_function(); + factory.register_alternative_function(); + factory.register_alternative_function(); + factory.register_alternative_function(); + factory.register_alternative_function(); + factory.register_alternative_function(); + factory.register_alternative_function(); + factory.register_alternative_function(); + factory.register_alternative_function(); + factory.register_alternative_function(); + factory.register_alternative_function(); + factory.register_alternative_function(); + factory.register_alternative_function(); + factory.register_alternative_function(); + factory.register_alternative_function(); + factory.register_alternative_function(); + factory.register_alternative_function(); + factory.register_alternative_function(); + factory.register_alternative_function(); + factory.register_alternative_function(); + factory.register_alternative_function(); + factory.register_alternative_function(); } } // namespace doris::vectorized diff --git a/be/test/vec/function/function_time_test.cpp b/be/test/vec/function/function_time_test.cpp index d942009a022d498..917e7b355980f8c 100644 --- a/be/test/vec/function/function_time_test.cpp +++ b/be/test/vec/function/function_time_test.cpp @@ -32,11 +32,11 @@ TEST(VTimestampFunctionsTest, day_of_week_test) { InputTypeSet input_types = {TypeIndex::DateTime}; - DataSet data_set = {{{std::string("2001-02-03 12:34:56")}, 7}, + DataSet data_set = {{{std::string("2001-02-03 12:34:56")}, int8_t {7}}, {{std::string("2020-00-01 00:00:00")}, Null()}, {{std::string("2020-01-00 00:00:00")}, Null()}}; - check_function(func_name, input_types, data_set); + check_function(func_name, input_types, data_set); } TEST(VTimestampFunctionsTest, day_of_month_test) { @@ -45,10 +45,10 @@ TEST(VTimestampFunctionsTest, day_of_month_test) { InputTypeSet input_types = {TypeIndex::DateTime}; DataSet data_set = {{{std::string("2020-00-01 00:00:00")}, Null()}, - {{std::string("2020-01-01 00:00:00")}, 1}, - {{std::string("2020-02-29 00:00:00")}, 29}}; + {{std::string("2020-01-01 00:00:00")}, int8_t {1}}, + {{std::string("2020-02-29 00:00:00")}, int8_t {29}}}; - check_function(func_name, input_types, data_set); + check_function(func_name, input_types, data_set); } TEST(VTimestampFunctionsTest, day_of_year_test) { @@ -58,9 +58,9 @@ TEST(VTimestampFunctionsTest, day_of_year_test) { DataSet data_set = {{{std::string("2020-00-01 00:00:00")}, Null()}, {{std::string("2020-01-00 00:00:00")}, Null()}, - {{std::string("2020-02-29 00:00:00")}, 60}}; + {{std::string("2020-02-29 00:00:00")}, int16_t {60}}}; - check_function(func_name, input_types, data_set); + check_function(func_name, input_types, data_set); } TEST(VTimestampFunctionsTest, week_of_year_test) { @@ -70,9 +70,9 @@ TEST(VTimestampFunctionsTest, week_of_year_test) { DataSet data_set = {{{std::string("2020-00-01 00:00:00")}, Null()}, {{std::string("2020-01-00 00:00:00")}, Null()}, - {{std::string("2020-02-29 00:00:00")}, 9}}; + {{std::string("2020-02-29 00:00:00")}, int8_t {9}}}; - check_function(func_name, input_types, data_set); + check_function(func_name, input_types, data_set); } TEST(VTimestampFunctionsTest, year_test) { @@ -80,11 +80,11 @@ TEST(VTimestampFunctionsTest, year_test) { InputTypeSet input_types = {TypeIndex::DateTime}; - DataSet data_set = {{{std::string("2021-01-01 00:00:00")}, 2021}, + DataSet data_set = {{{std::string("2021-01-01 00:00:00")}, int16_t {2021}}, {{std::string("2021-01-00 00:00:00")}, Null()}, - {{std::string("2025-05-01 00:00:00")}, 2025}}; + {{std::string("2025-05-01 00:00:00")}, int16_t {2025}}}; - check_function(func_name, input_types, data_set); + check_function(func_name, input_types, data_set); } TEST(VTimestampFunctionsTest, quarter_test) { @@ -92,12 +92,12 @@ TEST(VTimestampFunctionsTest, quarter_test) { InputTypeSet input_types = {TypeIndex::DateTime}; - DataSet data_set = {{{std::string("2021-01-01 00:00:00")}, 1}, + DataSet data_set = {{{std::string("2021-01-01 00:00:00")}, int8_t {1}}, {{std::string("")}, Null()}, {{std::string("2021-01-32 00:00:00")}, Null()}, - {{std::string("2025-10-23 00:00:00")}, 4}}; + {{std::string("2025-10-23 00:00:00")}, int8_t {4}}}; - check_function(func_name, input_types, data_set); + check_function(func_name, input_types, data_set); } TEST(VTimestampFunctionsTest, month_test) { @@ -105,12 +105,12 @@ TEST(VTimestampFunctionsTest, month_test) { InputTypeSet input_types = {TypeIndex::DateTime}; - DataSet data_set = {{{std::string("2021-01-01 00:00:00")}, 1}, + DataSet data_set = {{{std::string("2021-01-01 00:00:00")}, int8_t {1}}, {{std::string("")}, Null()}, {{std::string("2021-01-32 00:00:00")}, Null()}, - {{std::string("2025-05-23 00:00:00")}, 5}}; + {{std::string("2025-05-23 00:00:00")}, int8_t {5}}}; - check_function(func_name, input_types, data_set); + check_function(func_name, input_types, data_set); } TEST(VTimestampFunctionsTest, day_test) { @@ -118,12 +118,12 @@ TEST(VTimestampFunctionsTest, day_test) { InputTypeSet input_types = {TypeIndex::DateTime}; - DataSet data_set = {{{std::string("2021-01-01 00:00:00")}, 1}, + DataSet data_set = {{{std::string("2021-01-01 00:00:00")}, int8_t {1}}, {{std::string("")}, Null()}, {{std::string("2021-01-32 00:00:00")}, Null()}, - {{std::string("2025-05-23 00:00:00")}, 23}}; + {{std::string("2025-05-23 00:00:00")}, int8_t {23}}}; - check_function(func_name, input_types, data_set); + check_function(func_name, input_types, data_set); } TEST(VTimestampFunctionsTest, hour_test) { @@ -131,12 +131,12 @@ TEST(VTimestampFunctionsTest, hour_test) { InputTypeSet input_types = {TypeIndex::DateTime}; - DataSet data_set = {{{std::string("2021-01-01 23:59:59")}, 23}, - {{std::string("2021-01-13 16:56:00")}, 16}, + DataSet data_set = {{{std::string("2021-01-01 23:59:59")}, int8_t {23}}, + {{std::string("2021-01-13 16:56:00")}, int8_t {16}}, {{std::string("")}, Null()}, {{std::string("2025-05-23 24:00:00")}, Null()}}; - check_function(func_name, input_types, data_set); + check_function(func_name, input_types, data_set); } TEST(VTimestampFunctionsTest, minute_test) { @@ -144,12 +144,12 @@ TEST(VTimestampFunctionsTest, minute_test) { InputTypeSet input_types = {TypeIndex::DateTime}; - DataSet data_set = {{{std::string("2021-01-01 23:59:50")}, 59}, - {{std::string("2021-01-13 16:20:00")}, 20}, + DataSet data_set = {{{std::string("2021-01-01 23:59:50")}, int8_t {59}}, + {{std::string("2021-01-13 16:20:00")}, int8_t {20}}, {{std::string("")}, Null()}, {{std::string("2025-05-23 24:00:00")}, Null()}}; - check_function(func_name, input_types, data_set); + check_function(func_name, input_types, data_set); } TEST(VTimestampFunctionsTest, second_test) { @@ -157,12 +157,12 @@ TEST(VTimestampFunctionsTest, second_test) { InputTypeSet input_types = {TypeIndex::DateTime}; - DataSet data_set = {{{std::string("2021-01-01 23:50:59")}, 59}, - {{std::string("2021-01-13 16:20:00")}, 0}, + DataSet data_set = {{{std::string("2021-01-01 23:50:59")}, int8_t {59}}, + {{std::string("2021-01-13 16:20:00")}, int8_t {0}}, {{std::string("")}, Null()}, {{std::string("2025-05-23 24:00:00")}, Null()}}; - check_function(func_name, input_types, data_set); + check_function(func_name, input_types, data_set); } TEST(VTimestampFunctionsTest, from_unix_test) { @@ -478,18 +478,18 @@ TEST(VTimestampFunctionsTest, week_test) { InputTypeSet input_types = {TypeIndex::DateTime}; - DataSet data_set = {{{std::string("1989-03-21 06:00:00")}, 12}, + DataSet data_set = {{{std::string("1989-03-21 06:00:00")}, int8_t {12}}, {{std::string("")}, Null()}, - {{std::string("9999-12-12 00:00:00")}, 50}}; + {{std::string("9999-12-12 00:00:00")}, int8_t {50}}}; - check_function(func_name, input_types, data_set); + check_function(func_name, input_types, data_set); InputTypeSet new_input_types = {TypeIndex::Date}; - DataSet new_data_set = {{{std::string("1989-03-21")}, 12}, + DataSet new_data_set = {{{std::string("1989-03-21")}, int8_t {12}}, {{std::string("")}, Null()}, - {{std::string("9999-12-12")}, 50}}; + {{std::string("9999-12-12")}, int8_t {50}}}; - check_function(func_name, new_input_types, new_data_set); + check_function(func_name, new_input_types, new_data_set); } TEST(VTimestampFunctionsTest, yearweek_test) { @@ -548,21 +548,21 @@ TEST(VTimestampFunctionsTest, weekday_test) { { InputTypeSet input_types = {TypeIndex::DateTime}; - DataSet data_set = {{{std::string("2001-02-03 12:34:56")}, 5}, - {{std::string("2019-06-25")}, 1}, + DataSet data_set = {{{std::string("2001-02-03 12:34:56")}, int8_t {5}}, + {{std::string("2019-06-25")}, int8_t {1}}, {{std::string("2020-00-01 00:00:00")}, Null()}, {{std::string("2020-01-00 00:00:00")}, Null()}}; - check_function(func_name, input_types, data_set); + check_function(func_name, input_types, data_set); } InputTypeSet input_types = {TypeIndex::Date}; - DataSet data_set = {{{std::string("2001-02-03")}, 5}, - {{std::string("2019-06-25")}, 1}, + DataSet data_set = {{{std::string("2001-02-03")}, int8_t {5}}, + {{std::string("2019-06-25")}, int8_t {1}}, {{std::string("2020-00-01")}, Null()}, {{std::string("2020-01-00")}, Null()}}; - check_function(func_name, input_types, data_set); + check_function(func_name, input_types, data_set); } TEST(VTimestampFunctionsTest, day_of_week_v2_test) { @@ -571,26 +571,26 @@ TEST(VTimestampFunctionsTest, day_of_week_v2_test) { { InputTypeSet input_types = {TypeIndex::DateV2}; - DataSet data_set = {{{std::string("2001-02-03")}, 7}, + DataSet data_set = {{{std::string("2001-02-03")}, int8_t {7}}, {{std::string("2020-00-01")}, Null()}, {{std::string("2020-01-00")}, Null()}}; - check_function(func_name, input_types, data_set); + check_function(func_name, input_types, data_set); } { InputTypeSet input_types = {TypeIndex::DateTimeV2}; - DataSet data_set = {{{std::string("2001-02-03 01:00:00")}, 7}, - {{std::string("2001-02-03 01:00:00.213")}, 7}, - {{std::string("2001-02-03 01:00:00.123213")}, 7}, - {{std::string("2001-02-03 01:00:00.123123213")}, 7}, + DataSet data_set = {{{std::string("2001-02-03 01:00:00")}, int8_t {7}}, + {{std::string("2001-02-03 01:00:00.213")}, int8_t {7}}, + {{std::string("2001-02-03 01:00:00.123213")}, int8_t {7}}, + {{std::string("2001-02-03 01:00:00.123123213")}, int8_t {7}}, {{std::string("2001-02-03 25:00:00.123123213")}, Null()}, {{std::string("2001-02-03 01:61:00.123123213")}, Null()}, {{std::string("2001-02-03 01:00:61.123123213")}, Null()}, {{std::string("2020-00-01 01:00:00")}, Null()}, {{std::string("2020-01-00 01:00:00")}, Null()}}; - check_function(func_name, input_types, data_set); + check_function(func_name, input_types, data_set); } } @@ -601,19 +601,19 @@ TEST(VTimestampFunctionsTest, day_of_month_v2_test) { InputTypeSet input_types = {TypeIndex::DateV2}; DataSet data_set = {{{std::string("2020-00-01")}, Null()}, - {{std::string("2020-01-01")}, 1}, - {{std::string("2020-02-29")}, 29}}; + {{std::string("2020-01-01")}, int8_t {1}}, + {{std::string("2020-02-29")}, int8_t {29}}}; - check_function(func_name, input_types, data_set); + check_function(func_name, input_types, data_set); } { InputTypeSet input_types = {TypeIndex::DateTimeV2}; DataSet data_set = {{{std::string("2020-00-01 01:00:00")}, Null()}, - {{std::string("2020-01-01 01:00:00")}, 1}, - {{std::string("2020-02-29 01:00:00.123123")}, 29}}; + {{std::string("2020-01-01 01:00:00")}, int8_t {1}}, + {{std::string("2020-02-29 01:00:00.123123")}, int8_t {29}}}; - check_function(func_name, input_types, data_set); + check_function(func_name, input_types, data_set); } } @@ -625,18 +625,18 @@ TEST(VTimestampFunctionsTest, day_of_year_v2_test) { DataSet data_set = {{{std::string("2020-00-01")}, Null()}, {{std::string("2020-01-00")}, Null()}, - {{std::string("2020-02-29")}, 60}}; + {{std::string("2020-02-29")}, int16_t {60}}}; - check_function(func_name, input_types, data_set); + check_function(func_name, input_types, data_set); } { InputTypeSet input_types = {TypeIndex::DateTimeV2}; DataSet data_set = {{{std::string("2020-00-01 01:00:00")}, Null()}, {{std::string("2020-01-00 01:00:00")}, Null()}, - {{std::string("2020-02-29 01:00:00.1232")}, 60}}; + {{std::string("2020-02-29 01:00:00.1232")}, int16_t {60}}}; - check_function(func_name, input_types, data_set); + check_function(func_name, input_types, data_set); } } @@ -648,19 +648,19 @@ TEST(VTimestampFunctionsTest, week_of_year_v2_test) { DataSet data_set = {{{std::string("2020-00-01")}, Null()}, {{std::string("2020-01-00")}, Null()}, - {{std::string("2020-02-29")}, 9}}; + {{std::string("2020-02-29")}, int8_t {9}}}; - check_function(func_name, input_types, data_set); + check_function(func_name, input_types, data_set); } { InputTypeSet input_types = {TypeIndex::DateTimeV2}; DataSet data_set = {{{std::string("2020-00-01 01:00:00")}, Null()}, {{std::string("2020-01-00 01:00:00")}, Null()}, - {{std::string("2020-02-29 01:00:00")}, 9}, - {{std::string("2020-02-29 01:00:00.12312")}, 9}}; + {{std::string("2020-02-29 01:00:00")}, int8_t {9}}, + {{std::string("2020-02-29 01:00:00.12312")}, int8_t {9}}}; - check_function(func_name, input_types, data_set); + check_function(func_name, input_types, data_set); } } @@ -670,20 +670,20 @@ TEST(VTimestampFunctionsTest, year_v2_test) { { InputTypeSet input_types = {TypeIndex::DateV2}; - DataSet data_set = {{{std::string("2021-01-01")}, 2021}, + DataSet data_set = {{{std::string("2021-01-01")}, int16_t {2021}}, {{std::string("2021-01-00")}, Null()}, - {{std::string("2025-05-01")}, 2025}}; + {{std::string("2025-05-01")}, int16_t {2025}}}; - check_function(func_name, input_types, data_set); + check_function(func_name, input_types, data_set); } { InputTypeSet input_types = {TypeIndex::DateTimeV2}; - DataSet data_set = {{{std::string("2021-01-01 01:00:00")}, 2021}, + DataSet data_set = {{{std::string("2021-01-01 01:00:00")}, int16_t {2021}}, {{std::string("2021-01-00 01:00:00")}, Null()}, - {{std::string("2025-05-01 01:00:00.123")}, 2025}}; + {{std::string("2025-05-01 01:00:00.123")}, int16_t {2025}}}; - check_function(func_name, input_types, data_set); + check_function(func_name, input_types, data_set); } } @@ -693,22 +693,22 @@ TEST(VTimestampFunctionsTest, quarter_v2_test) { { InputTypeSet input_types = {TypeIndex::DateV2}; - DataSet data_set = {{{std::string("2021-01-01")}, 1}, + DataSet data_set = {{{std::string("2021-01-01")}, int8_t {1}}, {{std::string("")}, Null()}, {{std::string("2021-01-32")}, Null()}, - {{std::string("2025-10-23")}, 4}}; + {{std::string("2025-10-23")}, int8_t {4}}}; - check_function(func_name, input_types, data_set); + check_function(func_name, input_types, data_set); } { InputTypeSet input_types = {TypeIndex::DateTimeV2}; - DataSet data_set = {{{std::string("2021-01-01 00:00:00")}, 1}, + DataSet data_set = {{{std::string("2021-01-01 00:00:00")}, int8_t {1}}, {{std::string("")}, Null()}, {{std::string("2021-01-32 00:00:00")}, Null()}, - {{std::string("2025-10-23 00:00:00")}, 4}}; + {{std::string("2025-10-23 00:00:00")}, int8_t {4}}}; - check_function(func_name, input_types, data_set); + check_function(func_name, input_types, data_set); } } @@ -718,22 +718,22 @@ TEST(VTimestampFunctionsTest, month_v2_test) { { InputTypeSet input_types = {TypeIndex::DateV2}; - DataSet data_set = {{{std::string("2021-01-01")}, 1}, + DataSet data_set = {{{std::string("2021-01-01")}, int8_t {1}}, {{std::string("")}, Null()}, {{std::string("2021-01-32")}, Null()}, - {{std::string("2025-05-23")}, 5}}; + {{std::string("2025-05-23")}, int8_t {5}}}; - check_function(func_name, input_types, data_set); + check_function(func_name, input_types, data_set); } { InputTypeSet input_types = {TypeIndex::DateTimeV2}; - DataSet data_set = {{{std::string("2021-01-01 00:00:00")}, 1}, + DataSet data_set = {{{std::string("2021-01-01 00:00:00")}, int8_t {1}}, {{std::string("")}, Null()}, {{std::string("2021-01-32 00:00:00")}, Null()}, - {{std::string("2025-05-23 00:00:00")}, 5}}; + {{std::string("2025-05-23 00:00:00")}, int8_t {5}}}; - check_function(func_name, input_types, data_set); + check_function(func_name, input_types, data_set); } } @@ -743,22 +743,22 @@ TEST(VTimestampFunctionsTest, day_v2_test) { { InputTypeSet input_types = {TypeIndex::DateV2}; - DataSet data_set = {{{std::string("2021-01-01")}, 1}, + DataSet data_set = {{{std::string("2021-01-01")}, int8_t {1}}, {{std::string("")}, Null()}, {{std::string("2021-01-32")}, Null()}, - {{std::string("2025-05-23")}, 23}}; + {{std::string("2025-05-23")}, int8_t {23}}}; - check_function(func_name, input_types, data_set); + check_function(func_name, input_types, data_set); } { InputTypeSet input_types = {TypeIndex::DateTimeV2}; - DataSet data_set = {{{std::string("2021-01-01 00:00:00")}, 1}, + DataSet data_set = {{{std::string("2021-01-01 00:00:00")}, int8_t {1}}, {{std::string("")}, Null()}, {{std::string("2021-01-32 00:00:00")}, Null()}, - {{std::string("2025-05-23 00:00:00")}, 23}}; + {{std::string("2025-05-23 00:00:00")}, int8_t {23}}}; - check_function(func_name, input_types, data_set); + check_function(func_name, input_types, data_set); } } @@ -768,21 +768,21 @@ TEST(VTimestampFunctionsTest, hour_v2_test) { { InputTypeSet input_types = {TypeIndex::DateV2}; - DataSet data_set = {{{std::string("2021-01-01")}, 0}, - {{std::string("2021-01-13")}, 0}, + DataSet data_set = {{{std::string("2021-01-01")}, int8_t {0}}, + {{std::string("2021-01-13")}, int8_t {0}}, {{std::string("")}, Null()}, - {{std::string("2025-05-23")}, 0}}; - check_function(func_name, input_types, data_set); + {{std::string("2025-05-23")}, int8_t {0}}}; + check_function(func_name, input_types, data_set); } { InputTypeSet input_types = {TypeIndex::DateTimeV2}; - DataSet data_set = {{{std::string("2021-01-01 00:00:00.123")}, 0}, - {{std::string("2021-01-13 01:00:00.123")}, 1}, + DataSet data_set = {{{std::string("2021-01-01 00:00:00.123")}, int8_t {0}}, + {{std::string("2021-01-13 01:00:00.123")}, int8_t {1}}, {{std::string("")}, Null()}, - {{std::string("2025-05-23 23:00:00.123")}, 23}, + {{std::string("2025-05-23 23:00:00.123")}, int8_t {23}}, {{std::string("2025-05-23 25:00:00.123")}, Null()}}; - check_function(func_name, input_types, data_set); + check_function(func_name, input_types, data_set); } } @@ -792,23 +792,23 @@ TEST(VTimestampFunctionsTest, minute_v2_test) { { InputTypeSet input_types = {TypeIndex::DateV2}; - DataSet data_set = {{{std::string("2021-01-01")}, 0}, - {{std::string("2021-01-13")}, 0}, + DataSet data_set = {{{std::string("2021-01-01")}, int8_t {0}}, + {{std::string("2021-01-13")}, int8_t {0}}, {{std::string("")}, Null()}, - {{std::string("2025-05-23")}, 0}}; + {{std::string("2025-05-23")}, int8_t {0}}}; - check_function(func_name, input_types, data_set); + check_function(func_name, input_types, data_set); } { InputTypeSet input_types = {TypeIndex::DateTimeV2}; - DataSet data_set = {{{std::string("2021-01-01 00:00:00.123")}, 0}, - {{std::string("2021-01-13 00:11:00.123")}, 11}, + DataSet data_set = {{{std::string("2021-01-01 00:00:00.123")}, int8_t {0}}, + {{std::string("2021-01-13 00:11:00.123")}, int8_t {11}}, {{std::string("")}, Null()}, - {{std::string("2025-05-23 00:22:22.123")}, 22}, + {{std::string("2025-05-23 00:22:22.123")}, int8_t {22}}, {{std::string("2025-05-23 00:60:22.123")}, Null()}}; - check_function(func_name, input_types, data_set); + check_function(func_name, input_types, data_set); } } @@ -818,23 +818,23 @@ TEST(VTimestampFunctionsTest, second_v2_test) { { InputTypeSet input_types = {TypeIndex::DateV2}; - DataSet data_set = {{{std::string("2021-01-01")}, 0}, - {{std::string("2021-01-13")}, 0}, + DataSet data_set = {{{std::string("2021-01-01")}, int8_t {0}}, + {{std::string("2021-01-13")}, int8_t {0}}, {{std::string("")}, Null()}, - {{std::string("2025-05-23")}, 0}}; + {{std::string("2025-05-23")}, int8_t {0}}}; - check_function(func_name, input_types, data_set); + check_function(func_name, input_types, data_set); } { InputTypeSet input_types = {TypeIndex::DateTimeV2}; - DataSet data_set = {{{std::string("2021-01-01 00:00:01.123")}, 1}, - {{std::string("2021-01-13 00:00:02.123")}, 2}, + DataSet data_set = {{{std::string("2021-01-01 00:00:01.123")}, int8_t {1}}, + {{std::string("2021-01-13 00:00:02.123")}, int8_t {2}}, {{std::string("")}, Null()}, {{std::string("2025-05-23 00:00:63.123")}, Null()}, - {{std::string("2025-05-23 00:00:00.123")}, 0}}; + {{std::string("2025-05-23 00:00:00.123")}, int8_t {0}}}; - check_function(func_name, input_types, data_set); + check_function(func_name, input_types, data_set); } } @@ -1295,19 +1295,19 @@ TEST(VTimestampFunctionsTest, week_v2_test) { { InputTypeSet new_input_types = {TypeIndex::DateV2}; - DataSet new_data_set = {{{std::string("1989-03-21")}, 12}, + DataSet new_data_set = {{{std::string("1989-03-21")}, int8_t {12}}, {{std::string("")}, Null()}, - {{std::string("9999-12-12")}, 50}}; + {{std::string("9999-12-12")}, int8_t {50}}}; - check_function(func_name, new_input_types, new_data_set); + check_function(func_name, new_input_types, new_data_set); } { InputTypeSet new_input_types = {TypeIndex::DateTimeV2}; - DataSet new_data_set = {{{std::string("1989-03-21 00:00:11.123")}, 12}, + DataSet new_data_set = {{{std::string("1989-03-21 00:00:11.123")}, int8_t {12}}, {{std::string("")}, Null()}, - {{std::string("9999-12-12 00:00:11.123")}, 50}}; + {{std::string("9999-12-12 00:00:11.123")}, int8_t {50}}}; - check_function(func_name, new_input_types, new_data_set); + check_function(func_name, new_input_types, new_data_set); } } @@ -1367,22 +1367,22 @@ TEST(VTimestampFunctionsTest, weekday_v2_test) { { InputTypeSet input_types = {TypeIndex::DateV2}; - DataSet data_set = {{{std::string("2001-02-03")}, 5}, - {{std::string("2019-06-25")}, 1}, + DataSet data_set = {{{std::string("2001-02-03")}, int8_t {5}}, + {{std::string("2019-06-25")}, int8_t {1}}, {{std::string("2020-00-01")}, Null()}, {{std::string("2020-01-00")}, Null()}}; - check_function(func_name, input_types, data_set); + check_function(func_name, input_types, data_set); } { InputTypeSet input_types = {TypeIndex::DateTimeV2}; - DataSet data_set = {{{std::string("2001-02-03 00:00:11.123")}, 5}, - {{std::string("2019-06-25 00:00:11.123")}, 1}, + DataSet data_set = {{{std::string("2001-02-03 00:00:11.123")}, int8_t {5}}, + {{std::string("2019-06-25 00:00:11.123")}, int8_t {1}}, {{std::string("2020-00-01 00:00:11.123")}, Null()}, {{std::string("2020-01-00 00:00:11.123")}, Null()}}; - check_function(func_name, input_types, data_set); + check_function(func_name, input_types, data_set); } } diff --git a/fe/fe-common/src/main/java/org/apache/doris/common/Config.java b/fe/fe-common/src/main/java/org/apache/doris/common/Config.java index 1942ec08347a735..d7eb93d78f4d8fb 100644 --- a/fe/fe-common/src/main/java/org/apache/doris/common/Config.java +++ b/fe/fe-common/src/main/java/org/apache/doris/common/Config.java @@ -1807,7 +1807,7 @@ public class Config extends ConfigBase { * Max data version of backends serialize block. */ @ConfField(mutable = false) - public static int max_be_exec_version = 1; + public static int max_be_exec_version = 2; /** * Min data version of backends serialize block. diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/DayOfMonth.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/DayOfMonth.java index 5c7c8d54c99f85b..47401263944bc34 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/DayOfMonth.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/DayOfMonth.java @@ -26,7 +26,7 @@ import org.apache.doris.nereids.types.DateTimeType; import org.apache.doris.nereids.types.DateTimeV2Type; import org.apache.doris.nereids.types.DateV2Type; -import org.apache.doris.nereids.types.IntegerType; +import org.apache.doris.nereids.types.TinyIntType; import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableList; @@ -40,9 +40,9 @@ public class DayOfMonth extends ScalarFunction implements UnaryExpression, ExplicitlyCastableSignature, PropagateNullableOnDateLikeV2Args { public static final List SIGNATURES = ImmutableList.of( - FunctionSignature.ret(IntegerType.INSTANCE).args(DateTimeType.INSTANCE), - FunctionSignature.ret(IntegerType.INSTANCE).args(DateTimeV2Type.SYSTEM_DEFAULT), - FunctionSignature.ret(IntegerType.INSTANCE).args(DateV2Type.INSTANCE) + FunctionSignature.ret(TinyIntType.INSTANCE).args(DateTimeType.INSTANCE), + FunctionSignature.ret(TinyIntType.INSTANCE).args(DateTimeV2Type.SYSTEM_DEFAULT), + FunctionSignature.ret(TinyIntType.INSTANCE).args(DateV2Type.INSTANCE) ); /** diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/DayOfWeek.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/DayOfWeek.java index dc4df36e4c2330b..aede638b0139524 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/DayOfWeek.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/DayOfWeek.java @@ -26,7 +26,7 @@ import org.apache.doris.nereids.types.DateTimeType; import org.apache.doris.nereids.types.DateTimeV2Type; import org.apache.doris.nereids.types.DateV2Type; -import org.apache.doris.nereids.types.IntegerType; +import org.apache.doris.nereids.types.TinyIntType; import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableList; @@ -40,9 +40,9 @@ public class DayOfWeek extends ScalarFunction implements UnaryExpression, ExplicitlyCastableSignature, PropagateNullableOnDateLikeV2Args { public static final List SIGNATURES = ImmutableList.of( - FunctionSignature.ret(IntegerType.INSTANCE).args(DateTimeType.INSTANCE), - FunctionSignature.ret(IntegerType.INSTANCE).args(DateTimeV2Type.SYSTEM_DEFAULT), - FunctionSignature.ret(IntegerType.INSTANCE).args(DateV2Type.INSTANCE) + FunctionSignature.ret(TinyIntType.INSTANCE).args(DateTimeType.INSTANCE), + FunctionSignature.ret(TinyIntType.INSTANCE).args(DateTimeV2Type.SYSTEM_DEFAULT), + FunctionSignature.ret(TinyIntType.INSTANCE).args(DateV2Type.INSTANCE) ); /** diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/DayOfYear.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/DayOfYear.java index 668cbc505f0e4ed..2deb7357d81eba0 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/DayOfYear.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/DayOfYear.java @@ -26,7 +26,7 @@ import org.apache.doris.nereids.types.DateTimeType; import org.apache.doris.nereids.types.DateTimeV2Type; import org.apache.doris.nereids.types.DateV2Type; -import org.apache.doris.nereids.types.IntegerType; +import org.apache.doris.nereids.types.SmallIntType; import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableList; @@ -40,9 +40,9 @@ public class DayOfYear extends ScalarFunction implements UnaryExpression, ExplicitlyCastableSignature, PropagateNullableOnDateLikeV2Args { public static final List SIGNATURES = ImmutableList.of( - FunctionSignature.ret(IntegerType.INSTANCE).args(DateTimeType.INSTANCE), - FunctionSignature.ret(IntegerType.INSTANCE).args(DateTimeV2Type.SYSTEM_DEFAULT), - FunctionSignature.ret(IntegerType.INSTANCE).args(DateV2Type.INSTANCE) + FunctionSignature.ret(SmallIntType.INSTANCE).args(DateTimeType.INSTANCE), + FunctionSignature.ret(SmallIntType.INSTANCE).args(DateTimeV2Type.SYSTEM_DEFAULT), + FunctionSignature.ret(SmallIntType.INSTANCE).args(DateV2Type.INSTANCE) ); /** diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Hour.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Hour.java index 41c3e867ca9892a..9be1d31e327fbf4 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Hour.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Hour.java @@ -26,7 +26,7 @@ import org.apache.doris.nereids.types.DateTimeType; import org.apache.doris.nereids.types.DateTimeV2Type; import org.apache.doris.nereids.types.DateV2Type; -import org.apache.doris.nereids.types.IntegerType; +import org.apache.doris.nereids.types.TinyIntType; import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableList; @@ -40,9 +40,9 @@ public class Hour extends ScalarFunction implements UnaryExpression, ExplicitlyCastableSignature, PropagateNullableOnDateLikeV2Args { public static final List SIGNATURES = ImmutableList.of( - FunctionSignature.ret(IntegerType.INSTANCE).args(DateTimeType.INSTANCE), - FunctionSignature.ret(IntegerType.INSTANCE).args(DateTimeV2Type.SYSTEM_DEFAULT), - FunctionSignature.ret(IntegerType.INSTANCE).args(DateV2Type.INSTANCE) + FunctionSignature.ret(TinyIntType.INSTANCE).args(DateTimeType.INSTANCE), + FunctionSignature.ret(TinyIntType.INSTANCE).args(DateTimeV2Type.SYSTEM_DEFAULT), + FunctionSignature.ret(TinyIntType.INSTANCE).args(DateV2Type.INSTANCE) ); /** diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Minute.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Minute.java index bfd85568a145877..4bd860877105abf 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Minute.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Minute.java @@ -26,7 +26,7 @@ import org.apache.doris.nereids.types.DateTimeType; import org.apache.doris.nereids.types.DateTimeV2Type; import org.apache.doris.nereids.types.DateV2Type; -import org.apache.doris.nereids.types.IntegerType; +import org.apache.doris.nereids.types.TinyIntType; import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableList; @@ -40,9 +40,9 @@ public class Minute extends ScalarFunction implements UnaryExpression, ExplicitlyCastableSignature, PropagateNullableOnDateLikeV2Args { public static final List SIGNATURES = ImmutableList.of( - FunctionSignature.ret(IntegerType.INSTANCE).args(DateTimeType.INSTANCE), - FunctionSignature.ret(IntegerType.INSTANCE).args(DateTimeV2Type.SYSTEM_DEFAULT), - FunctionSignature.ret(IntegerType.INSTANCE).args(DateV2Type.INSTANCE) + FunctionSignature.ret(TinyIntType.INSTANCE).args(DateTimeType.INSTANCE), + FunctionSignature.ret(TinyIntType.INSTANCE).args(DateTimeV2Type.SYSTEM_DEFAULT), + FunctionSignature.ret(TinyIntType.INSTANCE).args(DateV2Type.INSTANCE) ); /** diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Month.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Month.java index b2c8ec39f026940..29556e705c96fdb 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Month.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Month.java @@ -26,7 +26,7 @@ import org.apache.doris.nereids.types.DateTimeType; import org.apache.doris.nereids.types.DateTimeV2Type; import org.apache.doris.nereids.types.DateV2Type; -import org.apache.doris.nereids.types.IntegerType; +import org.apache.doris.nereids.types.TinyIntType; import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableList; @@ -40,9 +40,9 @@ public class Month extends ScalarFunction implements UnaryExpression, ExplicitlyCastableSignature, PropagateNullableOnDateLikeV2Args { public static final List SIGNATURES = ImmutableList.of( - FunctionSignature.ret(IntegerType.INSTANCE).args(DateTimeType.INSTANCE), - FunctionSignature.ret(IntegerType.INSTANCE).args(DateTimeV2Type.SYSTEM_DEFAULT), - FunctionSignature.ret(IntegerType.INSTANCE).args(DateV2Type.INSTANCE) + FunctionSignature.ret(TinyIntType.INSTANCE).args(DateTimeType.INSTANCE), + FunctionSignature.ret(TinyIntType.INSTANCE).args(DateTimeV2Type.SYSTEM_DEFAULT), + FunctionSignature.ret(TinyIntType.INSTANCE).args(DateV2Type.INSTANCE) ); /** diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Quarter.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Quarter.java index bde752130069663..3a88b2dbe8f7b4b 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Quarter.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Quarter.java @@ -26,7 +26,7 @@ import org.apache.doris.nereids.types.DateTimeType; import org.apache.doris.nereids.types.DateTimeV2Type; import org.apache.doris.nereids.types.DateV2Type; -import org.apache.doris.nereids.types.IntegerType; +import org.apache.doris.nereids.types.TinyIntType; import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableList; @@ -40,9 +40,9 @@ public class Quarter extends ScalarFunction implements UnaryExpression, ExplicitlyCastableSignature, PropagateNullableOnDateLikeV2Args { public static final List SIGNATURES = ImmutableList.of( - FunctionSignature.ret(IntegerType.INSTANCE).args(DateTimeType.INSTANCE), - FunctionSignature.ret(IntegerType.INSTANCE).args(DateTimeV2Type.SYSTEM_DEFAULT), - FunctionSignature.ret(IntegerType.INSTANCE).args(DateV2Type.INSTANCE) + FunctionSignature.ret(TinyIntType.INSTANCE).args(DateTimeType.INSTANCE), + FunctionSignature.ret(TinyIntType.INSTANCE).args(DateTimeV2Type.SYSTEM_DEFAULT), + FunctionSignature.ret(TinyIntType.INSTANCE).args(DateV2Type.INSTANCE) ); /** diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Second.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Second.java index 6319e7d8181aff7..6b361471540cdf7 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Second.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Second.java @@ -26,7 +26,7 @@ import org.apache.doris.nereids.types.DateTimeType; import org.apache.doris.nereids.types.DateTimeV2Type; import org.apache.doris.nereids.types.DateV2Type; -import org.apache.doris.nereids.types.IntegerType; +import org.apache.doris.nereids.types.TinyIntType; import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableList; @@ -40,9 +40,9 @@ public class Second extends ScalarFunction implements UnaryExpression, ExplicitlyCastableSignature, PropagateNullableOnDateLikeV2Args { public static final List SIGNATURES = ImmutableList.of( - FunctionSignature.ret(IntegerType.INSTANCE).args(DateTimeType.INSTANCE), - FunctionSignature.ret(IntegerType.INSTANCE).args(DateTimeV2Type.SYSTEM_DEFAULT), - FunctionSignature.ret(IntegerType.INSTANCE).args(DateV2Type.INSTANCE) + FunctionSignature.ret(TinyIntType.INSTANCE).args(DateTimeType.INSTANCE), + FunctionSignature.ret(TinyIntType.INSTANCE).args(DateTimeV2Type.SYSTEM_DEFAULT), + FunctionSignature.ret(TinyIntType.INSTANCE).args(DateV2Type.INSTANCE) ); /** diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Week.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Week.java index ee27f81e4d1ebd5..51bdbdb07f2ac7c 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Week.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Week.java @@ -26,6 +26,7 @@ import org.apache.doris.nereids.types.DateTimeV2Type; import org.apache.doris.nereids.types.DateV2Type; import org.apache.doris.nereids.types.IntegerType; +import org.apache.doris.nereids.types.TinyIntType; import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableList; @@ -39,12 +40,12 @@ public class Week extends ScalarFunction implements ExplicitlyCastableSignature, PropagateNullableOnDateLikeV2Args { public static final List SIGNATURES = ImmutableList.of( - FunctionSignature.ret(IntegerType.INSTANCE).args(DateTimeType.INSTANCE), - FunctionSignature.ret(IntegerType.INSTANCE).args(DateTimeV2Type.SYSTEM_DEFAULT), - FunctionSignature.ret(IntegerType.INSTANCE).args(DateV2Type.INSTANCE), - FunctionSignature.ret(IntegerType.INSTANCE).args(DateTimeType.INSTANCE, IntegerType.INSTANCE), - FunctionSignature.ret(IntegerType.INSTANCE).args(DateTimeV2Type.SYSTEM_DEFAULT, IntegerType.INSTANCE), - FunctionSignature.ret(IntegerType.INSTANCE).args(DateV2Type.INSTANCE, IntegerType.INSTANCE) + FunctionSignature.ret(TinyIntType.INSTANCE).args(DateTimeType.INSTANCE), + FunctionSignature.ret(TinyIntType.INSTANCE).args(DateTimeV2Type.SYSTEM_DEFAULT), + FunctionSignature.ret(TinyIntType.INSTANCE).args(DateV2Type.INSTANCE), + FunctionSignature.ret(TinyIntType.INSTANCE).args(DateTimeType.INSTANCE, IntegerType.INSTANCE), + FunctionSignature.ret(TinyIntType.INSTANCE).args(DateTimeV2Type.SYSTEM_DEFAULT, IntegerType.INSTANCE), + FunctionSignature.ret(TinyIntType.INSTANCE).args(DateV2Type.INSTANCE, IntegerType.INSTANCE) ); /** diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/WeekOfYear.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/WeekOfYear.java index bab7824cac91207..666f8be866cce74 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/WeekOfYear.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/WeekOfYear.java @@ -26,7 +26,7 @@ import org.apache.doris.nereids.types.DateTimeType; import org.apache.doris.nereids.types.DateTimeV2Type; import org.apache.doris.nereids.types.DateV2Type; -import org.apache.doris.nereids.types.IntegerType; +import org.apache.doris.nereids.types.TinyIntType; import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableList; @@ -40,9 +40,9 @@ public class WeekOfYear extends ScalarFunction implements UnaryExpression, ExplicitlyCastableSignature, PropagateNullableOnDateLikeV2Args { public static final List SIGNATURES = ImmutableList.of( - FunctionSignature.ret(IntegerType.INSTANCE).args(DateTimeType.INSTANCE), - FunctionSignature.ret(IntegerType.INSTANCE).args(DateTimeV2Type.SYSTEM_DEFAULT), - FunctionSignature.ret(IntegerType.INSTANCE).args(DateV2Type.INSTANCE) + FunctionSignature.ret(TinyIntType.INSTANCE).args(DateTimeType.INSTANCE), + FunctionSignature.ret(TinyIntType.INSTANCE).args(DateTimeV2Type.SYSTEM_DEFAULT), + FunctionSignature.ret(TinyIntType.INSTANCE).args(DateV2Type.INSTANCE) ); /** diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Weekday.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Weekday.java index ecedbfb402cc6d2..c8700c01191f238 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Weekday.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Weekday.java @@ -26,7 +26,7 @@ import org.apache.doris.nereids.types.DateTimeType; import org.apache.doris.nereids.types.DateTimeV2Type; import org.apache.doris.nereids.types.DateV2Type; -import org.apache.doris.nereids.types.IntegerType; +import org.apache.doris.nereids.types.TinyIntType; import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableList; @@ -40,9 +40,9 @@ public class Weekday extends ScalarFunction implements UnaryExpression, ExplicitlyCastableSignature, PropagateNullableOnDateLikeV2Args { public static final List SIGNATURES = ImmutableList.of( - FunctionSignature.ret(IntegerType.INSTANCE).args(DateTimeType.INSTANCE), - FunctionSignature.ret(IntegerType.INSTANCE).args(DateTimeV2Type.SYSTEM_DEFAULT), - FunctionSignature.ret(IntegerType.INSTANCE).args(DateV2Type.INSTANCE) + FunctionSignature.ret(TinyIntType.INSTANCE).args(DateTimeType.INSTANCE), + FunctionSignature.ret(TinyIntType.INSTANCE).args(DateTimeV2Type.SYSTEM_DEFAULT), + FunctionSignature.ret(TinyIntType.INSTANCE).args(DateV2Type.INSTANCE) ); /** diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Year.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Year.java index e49e297dc8984ce..a51a925498c87d1 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Year.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Year.java @@ -26,7 +26,7 @@ import org.apache.doris.nereids.types.DateTimeType; import org.apache.doris.nereids.types.DateTimeV2Type; import org.apache.doris.nereids.types.DateV2Type; -import org.apache.doris.nereids.types.IntegerType; +import org.apache.doris.nereids.types.SmallIntType; import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableList; @@ -40,9 +40,9 @@ public class Year extends ScalarFunction implements UnaryExpression, ExplicitlyCastableSignature, PropagateNullableOnDateLikeV2Args { public static final List SIGNATURES = ImmutableList.of( - FunctionSignature.ret(IntegerType.INSTANCE).args(DateV2Type.INSTANCE), - FunctionSignature.ret(IntegerType.INSTANCE).args(DateTimeType.INSTANCE), - FunctionSignature.ret(IntegerType.INSTANCE).args(DateTimeV2Type.SYSTEM_DEFAULT) + FunctionSignature.ret(SmallIntType.INSTANCE).args(DateV2Type.INSTANCE), + FunctionSignature.ret(SmallIntType.INSTANCE).args(DateTimeType.INSTANCE), + FunctionSignature.ret(SmallIntType.INSTANCE).args(DateTimeV2Type.SYSTEM_DEFAULT) ); /** diff --git a/fe/fe-core/src/main/java/org/apache/doris/rewrite/FEFunctions.java b/fe/fe-core/src/main/java/org/apache/doris/rewrite/FEFunctions.java index 314a8f300b43a02..5b8b4c9a6b23e79 100755 --- a/fe/fe-core/src/main/java/org/apache/doris/rewrite/FEFunctions.java +++ b/fe/fe-core/src/main/java/org/apache/doris/rewrite/FEFunctions.java @@ -77,7 +77,7 @@ public static IntLiteral dateDiff(LiteralExpr first, LiteralExpr second) throws return new IntLiteral(datediff, Type.INT); } - @FEFunction(name = "dayofweek", argTypes = {"DATETIME"}, returnType = "INT") + @FEFunction(name = "dayofweek", argTypes = {"DATETIME"}, returnType = "TINYINT") public static IntLiteral dayOfWeek(LiteralExpr date) throws AnalysisException { // use zellar algorithm. long year = ((DateLiteral) date).getYear(); @@ -197,17 +197,17 @@ public static DateLiteral secondsSub(LiteralExpr date, LiteralExpr second) throw return secondsAdd(date, new IntLiteral(-(int) second.getLongValue())); } - @FEFunction(name = "year", argTypes = { "DATETIME" }, returnType = "INT") + @FEFunction(name = "year", argTypes = { "DATETIME" }, returnType = "SMALLINT") public static IntLiteral year(LiteralExpr arg) throws AnalysisException { return new IntLiteral(((DateLiteral) arg).getYear(), Type.INT); } - @FEFunction(name = "month", argTypes = { "DATETIME" }, returnType = "INT") + @FEFunction(name = "month", argTypes = { "DATETIME" }, returnType = "TINYINT") public static IntLiteral month(LiteralExpr arg) throws AnalysisException { return new IntLiteral(((DateLiteral) arg).getMonth(), Type.INT); } - @FEFunction(name = "day", argTypes = { "DATETIME" }, returnType = "INT") + @FEFunction(name = "day", argTypes = { "DATETIME" }, returnType = "TINYINT") public static IntLiteral day(LiteralExpr arg) throws AnalysisException { return new IntLiteral(((DateLiteral) arg).getDay(), Type.INT); } @@ -292,7 +292,7 @@ public static DateLiteral utcTimestamp() { Type.DATETIME); } - @FEFunction(name = "hour", argTypes = {"DATETIME"}, returnType = "INT") + @FEFunction(name = "hour", argTypes = {"DATETIME"}, returnType = "TINYINT") public static IntLiteral hour(LiteralExpr arg) throws AnalysisException { if (arg instanceof DateLiteral) { return new IntLiteral(((DateLiteral) arg).getHour()); @@ -300,7 +300,7 @@ public static IntLiteral hour(LiteralExpr arg) throws AnalysisException { return null; } - @FEFunction(name = "minute", argTypes = {"DATETIME"}, returnType = "INT") + @FEFunction(name = "minute", argTypes = {"DATETIME"}, returnType = "TINYINT") public static IntLiteral minute(LiteralExpr arg) throws AnalysisException { if (arg instanceof DateLiteral) { return new IntLiteral(((DateLiteral) arg).getMinute()); @@ -308,7 +308,7 @@ public static IntLiteral minute(LiteralExpr arg) throws AnalysisException { return null; } - @FEFunction(name = "second", argTypes = {"DATETIME"}, returnType = "INT") + @FEFunction(name = "second", argTypes = {"DATETIME"}, returnType = "TINYINT") public static IntLiteral second(LiteralExpr arg) throws AnalysisException { if (arg instanceof DateLiteral) { return new IntLiteral(((DateLiteral) arg).getSecond()); diff --git a/fe/fe-core/src/main/java/org/apache/doris/task/AlterReplicaTask.java b/fe/fe-core/src/main/java/org/apache/doris/task/AlterReplicaTask.java index 43e85a1b5363918..9bdf4986fc571d1 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/task/AlterReplicaTask.java +++ b/fe/fe-core/src/main/java/org/apache/doris/task/AlterReplicaTask.java @@ -22,6 +22,7 @@ import org.apache.doris.analysis.Expr; import org.apache.doris.analysis.SlotRef; import org.apache.doris.catalog.Column; +import org.apache.doris.common.Config; import org.apache.doris.thrift.TAlterMaterializedViewParam; import org.apache.doris.thrift.TAlterTabletReqV2; import org.apache.doris.thrift.TAlterTabletType; @@ -112,6 +113,7 @@ public AlterJobV2.JobType getJobType() { public TAlterTabletReqV2 toThrift() { TAlterTabletReqV2 req = new TAlterTabletReqV2(baseTabletId, signature, baseSchemaHash, newSchemaHash); req.setAlterVersion(version); + req.setBeExecVersion(Config.be_exec_version); switch (jobType) { case ROLLUP: req.setAlterTabletType(TAlterTabletType.ROLLUP); diff --git a/gensrc/script/doris_builtins_functions.py b/gensrc/script/doris_builtins_functions.py index 4e33f3090d06085..e4c794823427d78 100644 --- a/gensrc/script/doris_builtins_functions.py +++ b/gensrc/script/doris_builtins_functions.py @@ -835,21 +835,21 @@ [['date_trunc'], 'DATETIMEV2', ['DATETIMEV2', 'VARCHAR'], 'ALWAYS_NULLABLE'], - [['year'], 'INT', ['DATETIME'], 'ALWAYS_NULLABLE'], - [['month'], 'INT', ['DATETIME'], 'ALWAYS_NULLABLE'], - [['quarter'], 'INT', ['DATETIME'], 'ALWAYS_NULLABLE'], - [['dayofweek'], 'INT', ['DATETIME'], 'ALWAYS_NULLABLE'], - [['weekday'], 'INT', ['DATETIME'], 'ALWAYS_NULLABLE'], - [['day', 'dayofmonth'], 'INT', ['DATETIME'], 'ALWAYS_NULLABLE'], - [['dayofyear'], 'INT', ['DATETIME'], 'ALWAYS_NULLABLE'], - [['weekofyear'], 'INT', ['DATETIME'], 'ALWAYS_NULLABLE'], + [['year'], 'SMALLINT', ['DATETIME'], 'ALWAYS_NULLABLE'], + [['month'], 'TINYINT', ['DATETIME'], 'ALWAYS_NULLABLE'], + [['quarter'], 'TINYINT', ['DATETIME'], 'ALWAYS_NULLABLE'], + [['dayofweek'], 'TINYINT', ['DATETIME'], 'ALWAYS_NULLABLE'], + [['weekday'], 'TINYINT', ['DATETIME'], 'ALWAYS_NULLABLE'], + [['day', 'dayofmonth'], 'TINYINT', ['DATETIME'], 'ALWAYS_NULLABLE'], + [['dayofyear'], 'SMALLINT', ['DATETIME'], 'ALWAYS_NULLABLE'], + [['weekofyear'], 'TINYINT', ['DATETIME'], 'ALWAYS_NULLABLE'], [['yearweek'], 'INT', ['DATETIME'], 'ALWAYS_NULLABLE'], [['yearweek'], 'INT', ['DATETIME', 'INT'], 'ALWAYS_NULLABLE'], - [['week'], 'INT', ['DATETIME'], 'ALWAYS_NULLABLE'], - [['week'], 'INT', ['DATETIME', 'INT'], 'ALWAYS_NULLABLE'], - [['hour'], 'INT', ['DATETIME'], 'ALWAYS_NULLABLE'], - [['minute'], 'INT', ['DATETIME'], 'ALWAYS_NULLABLE'], - [['second'], 'INT', ['DATETIME'], 'ALWAYS_NULLABLE'], + [['week'], 'TINYINT', ['DATETIME'], 'ALWAYS_NULLABLE'], + [['week'], 'TINYINT', ['DATETIME', 'INT'], 'ALWAYS_NULLABLE'], + [['hour'], 'TINYINT', ['DATETIME'], 'ALWAYS_NULLABLE'], + [['minute'], 'TINYINT', ['DATETIME'], 'ALWAYS_NULLABLE'], + [['second'], 'TINYINT', ['DATETIME'], 'ALWAYS_NULLABLE'], [['makedate'], 'DATE', ['INT', 'INT'], 'ALWAYS_NULLABLE'], [['years_add'], 'DATETIME', ['DATETIME', 'INT'], 'ALWAYS_NULLABLE'], @@ -953,37 +953,37 @@ [['to_days'], 'INT', ['DATEV2'], ''], [['time_to_sec'], 'INT', ['TIME'], ''], - [['year'], 'INT', ['DATETIMEV2'], ''], - [['month'], 'INT', ['DATETIMEV2'], ''], - [['quarter'], 'INT', ['DATETIMEV2'], ''], - [['dayofweek'], 'INT', ['DATETIMEV2'], ''], - [['weekday'], 'INT', ['DATETIMEV2'], ''], - [['day', 'dayofmonth'], 'INT', ['DATETIMEV2'], ''], - [['dayofyear'], 'INT', ['DATETIMEV2'], ''], - [['weekofyear'], 'INT', ['DATETIMEV2'], ''], + [['year'], 'SMALLINT', ['DATETIMEV2'], ''], + [['month'], 'TINYINT', ['DATETIMEV2'], ''], + [['quarter'], 'TINYINT', ['DATETIMEV2'], ''], + [['dayofweek'], 'TINYINT', ['DATETIMEV2'], ''], + [['weekday'], 'TINYINT', ['DATETIMEV2'], ''], + [['day', 'dayofmonth'], 'TINYINT', ['DATETIMEV2'], ''], + [['dayofyear'], 'SMALLINT', ['DATETIMEV2'], ''], + [['weekofyear'], 'TINYINT', ['DATETIMEV2'], ''], [['yearweek'], 'INT', ['DATETIMEV2'], ''], [['yearweek'], 'INT', ['DATETIMEV2', 'INT'], ''], - [['week'], 'INT', ['DATETIMEV2'], ''], - [['week'], 'INT', ['DATETIMEV2', 'INT'], ''], - [['hour'], 'INT', ['DATETIMEV2'], ''], - [['minute'], 'INT', ['DATETIMEV2'], ''], - [['second'], 'INT', ['DATETIMEV2'], ''], - - [['year'], 'INT', ['DATEV2'], ''], - [['month'], 'INT', ['DATEV2'], ''], - [['quarter'], 'INT', ['DATEV2'], ''], - [['dayofweek'], 'INT', ['DATEV2'], ''], - [['weekday'], 'INT', ['DATEV2'], ''], - [['day', 'dayofmonth'], 'INT', ['DATEV2'], ''], - [['dayofyear'], 'INT', ['DATEV2'], ''], - [['weekofyear'], 'INT', ['DATEV2'], ''], + [['week'], 'TINYINT', ['DATETIMEV2'], ''], + [['week'], 'TINYINT', ['DATETIMEV2', 'INT'], ''], + [['hour'], 'TINYINT', ['DATETIMEV2'], ''], + [['minute'], 'TINYINT', ['DATETIMEV2'], ''], + [['second'], 'TINYINT', ['DATETIMEV2'], ''], + + [['year'], 'SMALLINT', ['DATEV2'], ''], + [['month'], 'TINYINT', ['DATEV2'], ''], + [['quarter'], 'TINYINT', ['DATEV2'], ''], + [['dayofweek'], 'TINYINT', ['DATEV2'], ''], + [['weekday'], 'TINYINT', ['DATEV2'], ''], + [['day', 'dayofmonth'], 'TINYINT', ['DATEV2'], ''], + [['dayofyear'], 'SMALLINT', ['DATEV2'], ''], + [['weekofyear'], 'TINYINT', ['DATEV2'], ''], [['yearweek'], 'INT', ['DATEV2'], ''], [['yearweek'], 'INT', ['DATEV2', 'INT'], ''], - [['week'], 'INT', ['DATEV2'], ''], - [['week'], 'INT', ['DATEV2', 'INT'], ''], - [['hour'], 'INT', ['DATEV2'], ''], - [['minute'], 'INT', ['DATEV2'], ''], - [['second'], 'INT', ['DATEV2'], ''], + [['week'], 'TINYINT', ['DATEV2'], ''], + [['week'], 'TINYINT', ['DATEV2', 'INT'], ''], + [['hour'], 'TINYINT', ['DATEV2'], ''], + [['minute'], 'TINYINT', ['DATEV2'], ''], + [['second'], 'TINYINT', ['DATEV2'], ''], [['years_add'], 'DATETIMEV2', ['DATETIMEV2', 'INT'], ''], [['years_sub'], 'DATETIMEV2', ['DATETIMEV2', 'INT'], ''], diff --git a/gensrc/thrift/AgentService.thrift b/gensrc/thrift/AgentService.thrift index 41a33f935c6d2df..91b2927705bc0e2 100644 --- a/gensrc/thrift/AgentService.thrift +++ b/gensrc/thrift/AgentService.thrift @@ -166,6 +166,7 @@ struct TAlterTabletReqV2 { 8: optional TAlterTabletType alter_tablet_type = TAlterTabletType.SCHEMA_CHANGE 9: optional Descriptors.TDescriptorTable desc_tbl 10: optional list columns + 11: optional i32 be_exec_version = 0 } struct TAlterInvertedIndexReq {