This is an automated email from the ASF dual-hosted git repository.
gabriellee pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push:
new f9f539221f3 [fix](datetime) Added datetime compatibility logic (#25791)
f9f539221f3 is described below
commit f9f539221f36cdbb3648055a2330e4af10663844
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 8e20d14f793..fb2340ffaaa 100644
--- a/be/src/vec/functions/function_timestamp.cpp
+++ b/be/src/vec/functions/function_timestamp.cpp
@@ -75,11 +75,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) {
@@ -1272,8 +1272,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 FunctionDateTruncDate =
FunctionOtherTypesToDateType<DateTrunc<DataTypeDate>>;
using FunctionDateTruncDateV2 =
FunctionOtherTypesToDateType<DateTrunc<DataTypeDateV2>>;
@@ -1283,6 +1285,8 @@ using FunctionDateTruncDatetimeV2 =
FunctionOtherTypesToDateType<DateTrunc<DataT
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<FunctionDateTruncDate>();
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]