bkietz commented on code in PR #39908:
URL: https://github.com/apache/arrow/pull/39908#discussion_r1476439011
##########
cpp/src/arrow/compute/expression.cc:
##########
@@ -750,15 +750,23 @@ Result<Datum> ExecuteScalarExpression(const Expression&
expr, const ExecBatch& i
auto call = CallNotNull(expr);
- std::vector<Datum> arguments(call->arguments.size());
-
+ size_t num_args = call->arguments.size();
+ std::vector<Datum> arguments(num_args);
bool all_scalar = true;
- for (size_t i = 0; i < arguments.size(); ++i) {
- ARROW_ASSIGN_OR_RAISE(
- arguments[i], ExecuteScalarExpression(call->arguments[i], input,
exec_context));
- if (arguments[i].is_array()) {
- all_scalar = false;
+
+ if (num_args) {
Review Comment:
I'd prefer to see this special case produce an input length rather than
modify all_scalar, to make the goal more clear:
```suggestion
std::vector<Datum> arguments(call->arguments.size());
bool all_scalar = true;
for (size_t i = 0; i < arguments.size(); ++i) {
ARROW_ASSIGN_OR_RAISE(
arguments[i], ExecuteScalarExpression(call->arguments[i], input,
exec_context));
if (arguments[i].is_array()) {
all_scalar = false;
}
}
int64_t input_length;
if (!arguments.empty() && all_scalar) {
// all inputs are scalar, so use a 1-long batch to avoid
// computing input.length equivalent outputs
input_length = 1;
} else {
input_length = input.length;
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]