This is an automated email from the ASF dual-hosted git repository.
yiguolei pushed a commit to branch branch-4.0
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-4.0 by this push:
new 5710da8e97a branch-4.0: [refine](check)If the return of function does
not match, directly report an error. #56488 (#56526)
5710da8e97a is described below
commit 5710da8e97a43ae09baac05089fc9c210849bc7e
Author: github-actions[bot]
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Sun Sep 28 10:14:46 2025 +0800
branch-4.0: [refine](check)If the return of function does not match,
directly report an error. #56488 (#56526)
Cherry-picked from #56488
Co-authored-by: Mryange <[email protected]>
---
be/src/vec/functions/function.h | 6 ++--
.../vec/function/function_throw_exception_test.cpp | 38 ++++++++++++++++++++++
2 files changed, 41 insertions(+), 3 deletions(-)
diff --git a/be/src/vec/functions/function.h b/be/src/vec/functions/function.h
index 600327a7418..fd0862c73d5 100644
--- a/be/src/vec/functions/function.h
+++ b/be/src/vec/functions/function.h
@@ -290,12 +290,12 @@ public:
->get_primitive_type() == INVALID_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))) {
- LOG_WARNING(
+ throw doris::Exception(
+ ErrorCode::INTERNAL_ERROR,
"function return type check failed, function_name={}, "
- "expect_return_type={}, real_return_type={},
input_arguments={}",
+ "fe plan return type={}, be real return type={},
input_arguments={}",
get_name(), return_type->get_name(),
func_return_type->get_name(),
get_types_string(arguments));
- return nullptr;
}
return build_impl(arguments, return_type);
}
diff --git a/be/test/vec/function/function_throw_exception_test.cpp
b/be/test/vec/function/function_throw_exception_test.cpp
index 3239e53c4a0..37f8e5f35e4 100644
--- a/be/test/vec/function/function_throw_exception_test.cpp
+++ b/be/test/vec/function/function_throw_exception_test.cpp
@@ -46,8 +46,32 @@ public:
}
};
+class MockFunctionThrowExceptionNotMatchReturnType : public IFunction {
+public:
+ static constexpr auto name =
"mock_function_throw_exception_not_match_return_type";
+ static FunctionPtr create() {
+ return
std::make_shared<MockFunctionThrowExceptionNotMatchReturnType>();
+ }
+ String get_name() const override { return name; }
+ bool use_default_implementation_for_constants() const override { return
false; }
+
+ size_t get_number_of_arguments() const override { return 0; }
+
+ bool is_variadic() const override { return true; }
+
+ DataTypePtr get_return_type_impl(const DataTypes& arguments) const
override {
+ return std::make_shared<DataTypeFloat64>();
+ }
+
+ Status execute_impl(FunctionContext* context, Block& block, const
ColumnNumbers& arguments,
+ uint32_t result, size_t input_rows_count) const
override {
+ throw doris::Exception(ErrorCode::INTERNAL_ERROR, "BEUT TEST:
MockFunctionThrowException");
+ }
+};
+
void register_function_throw_exception(SimpleFunctionFactory& factory) {
factory.register_function<MockFunctionThrowException>();
+ factory.register_function<MockFunctionThrowExceptionNotMatchReturnType>();
}
TEST(FunctionThrowExceptionTest, test_throw_exception) {
@@ -61,4 +85,18 @@ TEST(FunctionThrowExceptionTest, test_throw_exception) {
EXPECT_EQ(st.code(), ErrorCode::INTERNAL_ERROR);
EXPECT_EQ(st.msg(), "BEUT TEST: MockFunctionThrowException");
}
+
+TEST(FunctionThrowExceptionTest, not_match_return_type) {
+ try {
+ auto function = SimpleFunctionFactory::instance().get_function(
+ "mock_function_throw_exception_not_match_return_type", {},
+ std::make_shared<DataTypeInt32>(), {false},
+ BeExecVersionManager::get_newest_version());
+
+ } catch (doris::Exception& e) {
+ EXPECT_EQ(e.code(), ErrorCode::INTERNAL_ERROR);
+ std::cout << "Exception msg: " << e.to_string() << std::endl;
+ }
+}
+
} // namespace doris::vectorized
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]