westonpace commented on code in PR #15083:
URL: https://github.com/apache/arrow/pull/15083#discussion_r1057263411
##########
cpp/src/arrow/compute/exec/test_util.cc:
##########
@@ -416,7 +416,19 @@ static inline void PrintToImpl(const std::string&
factory_name,
*os << "function=" << agg.function << "<";
if (agg.options) PrintTo(*agg.options, os);
*os << ">,";
- *os << "target=" << agg.target.ToString() << ",";
+ *os << "target=";
+ if (agg.target.size() == 0) {
+ *os << "*";
+ } else if (agg.target.size() == 1) {
+ *os << agg.target[0].ToString();
+ } else {
Review Comment:
Minor nit: we can probably get rid of this special `size() == 1` case since
it should be handled fine by the else case below.
##########
cpp/src/arrow/engine/substrait/extension_set.cc:
##########
@@ -883,21 +883,27 @@ ExtensionIdRegistry::SubstraitCallToArrow
DecodeConcatMapping() {
ExtensionIdRegistry::SubstraitAggregateToArrow DecodeBasicAggregate(
const std::string& arrow_function_name) {
return [arrow_function_name](const SubstraitCall& call) ->
Result<compute::Aggregate> {
- if (call.size() != 1) {
- return Status::NotImplemented(
- "Only unary aggregate functions are currently supported");
- }
- ARROW_ASSIGN_OR_RAISE(compute::Expression arg, call.GetValueArg(0));
- const FieldRef* arg_ref = arg.field_ref();
- if (!arg_ref) {
- return Status::Invalid("Expected an aggregate call ", call.id().uri, "#",
- call.id().name, " to have a direct reference");
- }
- std::string fixed_arrow_func = arrow_function_name;
+ std::string fixed_arrow_func;
if (call.is_hash()) {
- fixed_arrow_func = "hash_" + arrow_function_name;
+ fixed_arrow_func = "hash_";
+ }
+ fixed_arrow_func += arrow_function_name;
+
+ switch (call.size()) {
+ case 1: {
+ ARROW_ASSIGN_OR_RAISE(compute::Expression arg, call.GetValueArg(0));
+ const FieldRef* arg_ref = arg.field_ref();
+ if (!arg_ref) {
+ return Status::Invalid("Expected an aggregate call ", call.id().uri,
"#",
+ call.id().name, " to have a direct
reference");
+ }
+ return compute::Aggregate{std::move(fixed_arrow_func), *arg_ref};
+ }
+ default:
+ break;
Review Comment:
I'm not sure I follow. Why is this a switch statement and not an if
statement?
--
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]