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 343e3216b7e branch-4.0: [refine](function)In functions, ensure that an
empty input column returns an empty column. #60660 (#60696)
343e3216b7e is described below
commit 343e3216b7ef204d6571abc08c4059f32b23c791
Author: github-actions[bot]
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Thu Feb 12 23:34:01 2026 +0800
branch-4.0: [refine](function)In functions, ensure that an empty input
column returns an empty column. #60660 (#60696)
Cherry-picked from #60660
Co-authored-by: Mryange <[email protected]>
---
be/src/vec/functions/function.h | 10 ++++++++++
be/src/vec/functions/function_const.h | 3 +--
2 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/be/src/vec/functions/function.h b/be/src/vec/functions/function.h
index 5a38216827c..9efe3fee906 100644
--- a/be/src/vec/functions/function.h
+++ b/be/src/vec/functions/function.h
@@ -184,6 +184,16 @@ public:
Status execute(FunctionContext* context, Block& block, const
ColumnNumbers& arguments,
uint32_t result, size_t input_rows_count) const {
+ // Some function implementations may not handle the case where
input_rows_count is 0
+ // (e.g., some functions access the 0th row of input columns during
execution).
+ // Additionally, some UDF functions may hang if they write 0 rows and
then try to read.
+ // Therefore, before executing the function, we first check if
input_rows_count is 0.
+ // If it is 0, we directly return an empty result column to avoid
executing the function body.
+ if (input_rows_count == 0) {
+ block.get_by_position(result).column =
+ block.get_by_position(result).type->create_column();
+ return Status::OK();
+ }
try {
return prepare(context, block, arguments, result)
->execute(context, block, arguments, result,
input_rows_count);
diff --git a/be/src/vec/functions/function_const.h
b/be/src/vec/functions/function_const.h
index 280dda6f343..c56c924b8ec 100644
--- a/be/src/vec/functions/function_const.h
+++ b/be/src/vec/functions/function_const.h
@@ -92,8 +92,7 @@ private:
uint32_t result, size_t input_rows_count) const
override {
block.get_by_position(result).column =
block.get_by_position(result).type->create_column_const(
- input_rows_count == 0 ? 1 : input_rows_count,
- Field::create_field<TYPE_DOUBLE>(Impl::value));
+ input_rows_count,
Field::create_field<TYPE_DOUBLE>(Impl::value));
return Status::OK();
}
};
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]