This is an automated email from the ASF dual-hosted git repository. kxiao pushed a commit to branch branch-2.0 in repository https://gitbox.apache.org/repos/asf/doris.git
commit 54ac78ffe3a2c7c4cedbcf864030ad43bdbfc8a6 Author: zclllyybb <[email protected]> AuthorDate: Tue Oct 24 10:37:57 2023 +0800 [fix](datetime) Added datetime compatibility logic (#25791) --- be/src/vec/functions/function.cpp | 7 +++++++ be/src/vec/functions/function_timestamp.cpp | 16 ++++++++++------ 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/be/src/vec/functions/function.cpp b/be/src/vec/functions/function.cpp index 1a92f475cbd..031b8e755b4 100644 --- a/be/src/vec/functions/function.cpp +++ b/be/src/vec/functions/function.cpp @@ -353,6 +353,13 @@ bool FunctionBuilderImpl::is_date_or_datetime_or_decimal( func_return_type->is_nullable() ? ((DataTypeNullable*)func_return_type.get())->get_nested_type() : func_return_type)) || + (is_date_or_datetime(return_type->is_nullable() + ? ((DataTypeNullable*)return_type.get())->get_nested_type() + : return_type) && + is_date_v2_or_datetime_v2( + func_return_type->is_nullable() + ? ((DataTypeNullable*)func_return_type.get())->get_nested_type() + : func_return_type)) || (is_decimal(return_type->is_nullable() ? ((DataTypeNullable*)return_type.get())->get_nested_type() : return_type) && diff --git a/be/src/vec/functions/function_timestamp.cpp b/be/src/vec/functions/function_timestamp.cpp index 48ceb6cbb4f..e928e40ce30 100644 --- a/be/src/vec/functions/function_timestamp.cpp +++ b/be/src/vec/functions/function_timestamp.cpp @@ -74,11 +74,11 @@ struct StrToDate { } static DataTypePtr get_return_type_impl(const DataTypes& arguments) { - if constexpr (IsDateType<DateType> || IsDateV2Type<DateType>) { - return make_nullable(std::make_shared<DataTypeDateV2>()); + if constexpr (IsDataTypeDateTimeV2<DateType>) { + // max scale + return make_nullable(std::make_shared<DataTypeDateTimeV2>(6)); } - //datetimev2 - return make_nullable(std::make_shared<DataTypeDateTimeV2>(6)); + return make_nullable(std::make_shared<DateType>()); } static StringRef rewrite_specific_format(const char* raw_str, size_t str_size) { @@ -1276,8 +1276,10 @@ public: } }; -using FunctionStrToDate = FunctionOtherTypesToDateType<StrToDate<DataTypeDateV2>>; -using FunctionStrToDatetime = FunctionOtherTypesToDateType<StrToDate<DataTypeDateTimeV2>>; +using FunctionStrToDate = FunctionOtherTypesToDateType<StrToDate<DataTypeDate>>; +using FunctionStrToDatetime = FunctionOtherTypesToDateType<StrToDate<DataTypeDateTime>>; +using FunctionStrToDateV2 = FunctionOtherTypesToDateType<StrToDate<DataTypeDateV2>>; +using FunctionStrToDatetimeV2 = FunctionOtherTypesToDateType<StrToDate<DataTypeDateTimeV2>>; using FunctionMakeDate = FunctionOtherTypesToDateType<MakeDateImpl>; using FunctionDateTrunc = FunctionOtherTypesToDateType<DateTrunc<VecDateTimeValue, Int64>>; using FunctionDateTruncV2 = @@ -1286,6 +1288,8 @@ using FunctionDateTruncV2 = void register_function_timestamp(SimpleFunctionFactory& factory) { factory.register_function<FunctionStrToDate>(); factory.register_function<FunctionStrToDatetime>(); + factory.register_function<FunctionStrToDateV2>(); + factory.register_function<FunctionStrToDatetimeV2>(); factory.register_function<FunctionMakeDate>(); factory.register_function<FromDays>(); factory.register_function<FunctionDateTrunc>(); --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
