This is an automated email from the ASF dual-hosted git repository.
Mryange 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 266450541d2 [opt](function) reuse input column for positive (#69715)
266450541d2 is described below
commit 266450541d29765bff48d4bfc681620865b6c674
Author: Mryange <[email protected]>
AuthorDate: Thu Oct 29 09:57:48 2026 +0800
[opt](function) reuse input column for positive (#69715)
### What problem does this PR solve?
`positive()` allocates and copies a result column even though it
preserves its input values and type. Reuse the immutable input column
for non-Decimal arguments to avoid this work.
### Release note
Reduce CPU and allocation overhead of non-Decimal `positive()`
expressions.
### Check List (For Author)
- Test
- [x] Manual test: Built and ran the same patch on ARM. Checked
`count(positive(u64)), count(positive(f64))` over 20 million rows, plus
negative, zero, positive, NULL, floating-point and nullable aggregate
inputs. Results were correct. This checkout was not rebuilt.
- [x] Formatting, `git diff --check`, and `bash
build-support/check-build-hygiene.sh` passed.
- Behavior changed:
- [x] No.
- Does this need documentation?
- [x] No.
### Check List (For Reviewer who merge this PR)
- [ ] Confirm the release note
- [ ] Confirm test cases
- [ ] Confirm document
---
be/src/exprs/function/function_unary_arithmetic.h | 20 +++++++++++++-------
1 file changed, 13 insertions(+), 7 deletions(-)
diff --git a/be/src/exprs/function/function_unary_arithmetic.h
b/be/src/exprs/function/function_unary_arithmetic.h
index cf7ac5dfbfb..dd28e3ac242 100644
--- a/be/src/exprs/function/function_unary_arithmetic.h
+++ b/be/src/exprs/function/function_unary_arithmetic.h
@@ -141,13 +141,19 @@ public:
} else {
if (auto col =
check_and_get_column<ColumnVector<DataType::PType>>(
block.get_by_position(arguments[0]).column.get())) {
- auto col_res =
-
PrimitiveTypeTraits<Op::ResultType>::ColumnType::create();
- auto& vec_res = col_res->get_data();
- vec_res.resize(col->get_data().size());
- UnaryOperationImpl<DataType::PType,
Op>::vector(col->get_data(),
-
vec_res);
- block.replace_by_position(result,
std::move(col_res));
+ if constexpr (std::string_view(Name::name) ==
"positive") {
+ // Positive preserves the type, so its
immutable input can be shared.
+ block.replace_by_position(
+ result,
block.get_by_position(arguments[0]).column);
+ } else {
+ auto col_res =
+
PrimitiveTypeTraits<Op::ResultType>::ColumnType::create();
+ auto& vec_res = col_res->get_data();
+ vec_res.resize(col->get_data().size());
+ UnaryOperationImpl<DataType::PType,
Op>::vector(col->get_data(),
+
vec_res);
+ block.replace_by_position(result,
std::move(col_res));
+ }
return true;
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]