Skip to content

Commit

Permalink
remove
Browse files Browse the repository at this point in the history
  • Loading branch information
koarz committed Nov 29, 2024
1 parent 0ffb71b commit 3b217de
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 79 deletions.
71 changes: 0 additions & 71 deletions be/src/vec/functions/function.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -293,75 +293,4 @@ DataTypePtr FunctionBuilderImpl::get_return_type(const ColumnsWithTypeAndName& a

return get_return_type_without_low_cardinality(arguments);
}

bool FunctionBuilderImpl::is_date_or_datetime_or_decimal(
const DataTypePtr& return_type, const DataTypePtr& func_return_type) const {
return (is_date_or_datetime(return_type->is_nullable()
? ((DataTypeNullable*)return_type.get())->get_nested_type()
: return_type) &&
is_date_or_datetime(
func_return_type->is_nullable()
? ((DataTypeNullable*)func_return_type.get())->get_nested_type()
: func_return_type)) ||
(is_date_v2_or_datetime_v2(
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)) ||
// For some date functions such as str_to_date(string, string), return_type will
// be datetimev2 if users enable datev2 but get_return_type(arguments) will still
// return datetime. We need keep backward compatibility here.
(is_date_v2_or_datetime_v2(
return_type->is_nullable()
? ((DataTypeNullable*)return_type.get())->get_nested_type()
: return_type) &&
is_date_or_datetime(
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) &&
is_decimal(func_return_type->is_nullable()
? ((DataTypeNullable*)func_return_type.get())->get_nested_type()
: func_return_type));
}

bool FunctionBuilderImpl::is_array_nested_type_date_or_datetime_or_decimal(
const DataTypePtr& return_type, const DataTypePtr& func_return_type) const {
auto return_type_ptr = return_type->is_nullable()
? ((DataTypeNullable*)return_type.get())->get_nested_type()
: return_type;
auto func_return_type_ptr =
func_return_type->is_nullable()
? ((DataTypeNullable*)func_return_type.get())->get_nested_type()
: func_return_type;
if (!(is_array(return_type_ptr) && is_array(func_return_type_ptr))) {
return false;
}
auto nested_nullable_return_type_ptr =
(assert_cast<const DataTypeArray*>(return_type_ptr.get()))->get_nested_type();
auto nested_nullable_func_return_type =
(assert_cast<const DataTypeArray*>(func_return_type_ptr.get()))->get_nested_type();
// There must be nullable inside array type.
if (nested_nullable_return_type_ptr->is_nullable() &&
nested_nullable_func_return_type->is_nullable()) {
auto nested_return_type_ptr =
((DataTypeNullable*)(nested_nullable_return_type_ptr.get()))->get_nested_type();
auto nested_func_return_type_ptr =
((DataTypeNullable*)(nested_nullable_func_return_type.get()))->get_nested_type();
return is_date_or_datetime_or_decimal(nested_return_type_ptr, nested_func_return_type_ptr);
}
return false;
}
} // namespace doris::vectorized
9 changes: 1 addition & 8 deletions be/src/vec/functions/function.h
Original file line number Diff line number Diff line change
Expand Up @@ -271,9 +271,7 @@ class FunctionBuilderImpl : public IFunctionBuilder {
// For null constant argument, `get_return_type` would return
// Nullable<DataTypeNothing> when `use_default_implementation_for_nulls` is true.
(return_type->is_nullable() && func_return_type->is_nullable() &&
is_nothing(((DataTypeNullable*)func_return_type.get())->get_nested_type())) ||
is_date_or_datetime_or_decimal(return_type, func_return_type) ||
is_array_nested_type_date_or_datetime_or_decimal(return_type, func_return_type))) {
is_nothing(((DataTypeNullable*)func_return_type.get())->get_nested_type())))) {
LOG_WARNING(
"function return type check failed, function_name={}, "
"expect_return_type={}, real_return_type={}, input_arguments={}",
Expand Down Expand Up @@ -344,11 +342,6 @@ class FunctionBuilderImpl : public IFunctionBuilder {
private:
DataTypePtr get_return_type_without_low_cardinality(
const ColumnsWithTypeAndName& arguments) const;

bool is_date_or_datetime_or_decimal(const DataTypePtr& return_type,
const DataTypePtr& func_return_type) const;
bool is_array_nested_type_date_or_datetime_or_decimal(
const DataTypePtr& return_type, const DataTypePtr& func_return_type) const;
};

/// Previous function interface.
Expand Down

0 comments on commit 3b217de

Please sign in to comment.