@@ -43,18 +43,16 @@ namespace compute {
4343
4444namespace {
4545
46- void AggregatesToString (
47- std::stringstream* ss, const Schema& input_schema,
48- const std::vector<internal::Aggregate>& aggs,
49- const std::vector<int >& target_field_ids,
50- const std::vector<std::unique_ptr<FunctionOptions>>& owned_options, int indent = 0 ) {
46+ void AggregatesToString (std::stringstream* ss, const Schema& input_schema,
47+ const std::vector<internal::Aggregate>& aggs,
48+ const std::vector<int >& target_field_ids, int indent = 0 ) {
5149 *ss << " aggregates=[" << std::endl;
5250 for (size_t i = 0 ; i < aggs.size (); i++) {
5351 for (int j = 0 ; j < indent; ++j) *ss << " " ;
5452 *ss << ' \t ' << aggs[i].function << ' ('
5553 << input_schema.field (target_field_ids[i])->name ();
56- if (owned_options [i]) {
57- *ss << " , " << owned_options [i]->ToString ();
54+ if (aggs [i]. options ) {
55+ *ss << " , " << aggs [i]. options ->ToString ();
5856 }
5957 *ss << " )," << std::endl;
6058 }
@@ -69,16 +67,14 @@ class ScalarAggregateNode : public ExecNode {
6967 std::vector<int > target_field_ids,
7068 std::vector<internal::Aggregate> aggs,
7169 std::vector<const ScalarAggregateKernel*> kernels,
72- std::vector<std::vector<std::unique_ptr<KernelState>>> states,
73- std::vector<std::unique_ptr<FunctionOptions>> owned_options)
70+ std::vector<std::vector<std::unique_ptr<KernelState>>> states)
7471 : ExecNode(plan, std::move(inputs), {" target" },
7572 /* output_schema=*/ std::move(output_schema),
7673 /* num_outputs=*/ 1 ),
7774 target_field_ids_ (std::move(target_field_ids)),
7875 aggs_(std::move(aggs)),
7976 kernels_(std::move(kernels)),
80- states_(std::move(states)),
81- owned_options_(std::move(owned_options)) {}
77+ states_(std::move(states)) {}
8278
8379 static Result<ExecNode*> Make (ExecPlan* plan, std::vector<ExecNode*> inputs,
8480 const ExecNodeOptions& options) {
@@ -95,7 +91,6 @@ class ScalarAggregateNode : public ExecNode {
9591 FieldVector fields (kernels.size ());
9692 const auto & field_names = aggregate_options.names ;
9793 std::vector<int > target_field_ids (kernels.size ());
98- std::vector<std::unique_ptr<FunctionOptions>> owned_options (aggregates.size ());
9994
10095 for (size_t i = 0 ; i < kernels.size (); ++i) {
10196 ARROW_ASSIGN_OR_RAISE (auto match,
@@ -116,11 +111,7 @@ class ScalarAggregateNode : public ExecNode {
116111 kernels[i] = static_cast <const ScalarAggregateKernel*>(kernel);
117112
118113 if (aggregates[i].options == nullptr ) {
119- aggregates[i].options = function->default_options ();
120- }
121- if (aggregates[i].options ) {
122- owned_options[i] = aggregates[i].options ->Copy ();
123- aggregates[i].options = owned_options[i].get ();
114+ aggregates[i].options = function->default_options ()->Copy ();
124115 }
125116
126117 KernelContext kernel_ctx{exec_ctx};
@@ -130,7 +121,7 @@ class ScalarAggregateNode : public ExecNode {
130121 {
131122 in_type,
132123 },
133- aggregates[i].options },
124+ aggregates[i].options . get () },
134125 &states[i]));
135126
136127 // pick one to resolve the kernel signature
@@ -143,8 +134,7 @@ class ScalarAggregateNode : public ExecNode {
143134
144135 return plan->EmplaceNode <ScalarAggregateNode>(
145136 plan, std::move (inputs), schema (std::move (fields)), std::move (target_field_ids),
146- std::move (aggregates), std::move (kernels), std::move (states),
147- std::move (owned_options));
137+ std::move (aggregates), std::move (kernels), std::move (states));
148138 }
149139
150140 const char * kind_name () const override { return " ScalarAggregateNode" ; }
@@ -242,7 +232,7 @@ class ScalarAggregateNode : public ExecNode {
242232 std::string ToStringExtra (int indent = 0 ) const override {
243233 std::stringstream ss;
244234 const auto input_schema = inputs_[0 ]->output_schema ();
245- AggregatesToString (&ss, *input_schema, aggs_, target_field_ids_, owned_options_ );
235+ AggregatesToString (&ss, *input_schema, aggs_, target_field_ids_);
246236 return ss.str ();
247237 }
248238
@@ -277,7 +267,6 @@ class ScalarAggregateNode : public ExecNode {
277267 const std::vector<const ScalarAggregateKernel*> kernels_;
278268
279269 std::vector<std::vector<std::unique_ptr<KernelState>>> states_;
280- const std::vector<std::unique_ptr<FunctionOptions>> owned_options_;
281270
282271 ThreadIndexer get_thread_index_;
283272 AtomicCounter input_counter_;
@@ -288,16 +277,14 @@ class GroupByNode : public ExecNode {
288277 GroupByNode (ExecNode* input, std::shared_ptr<Schema> output_schema, ExecContext* ctx,
289278 std::vector<int > key_field_ids, std::vector<int > agg_src_field_ids,
290279 std::vector<internal::Aggregate> aggs,
291- std::vector<const HashAggregateKernel*> agg_kernels,
292- std::vector<std::unique_ptr<FunctionOptions>> owned_options)
280+ std::vector<const HashAggregateKernel*> agg_kernels)
293281 : ExecNode(input->plan (), {input}, {" groupby" }, std::move(output_schema),
294282 /* num_outputs=*/ 1 ),
295283 ctx_ (ctx),
296284 key_field_ids_(std::move(key_field_ids)),
297285 agg_src_field_ids_(std::move(agg_src_field_ids)),
298286 aggs_(std::move(aggs)),
299- agg_kernels_(std::move(agg_kernels)),
300- owned_options_(std::move(owned_options)) {}
287+ agg_kernels_(std::move(agg_kernels)) {}
301288
302289 static Result<ExecNode*> Make (ExecPlan* plan, std::vector<ExecNode*> inputs,
303290 const ExecNodeOptions& options) {
@@ -363,17 +350,9 @@ class GroupByNode : public ExecNode {
363350 output_fields[base + i] = input_schema->field (key_field_id);
364351 }
365352
366- std::vector<std::unique_ptr<FunctionOptions>> owned_options;
367- owned_options.reserve (aggs.size ());
368- for (auto & agg : aggs) {
369- owned_options.push_back (agg.options ? agg.options ->Copy () : nullptr );
370- agg.options = owned_options.back ().get ();
371- }
372-
373353 return input->plan ()->EmplaceNode <GroupByNode>(
374354 input, schema (std::move (output_fields)), ctx, std::move (key_field_ids),
375- std::move (agg_src_field_ids), std::move (aggs), std::move (agg_kernels),
376- std::move (owned_options));
355+ std::move (agg_src_field_ids), std::move (aggs), std::move (agg_kernels));
377356 }
378357
379358 const char * kind_name () const override { return " GroupByNode" ; }
@@ -623,8 +602,7 @@ class GroupByNode : public ExecNode {
623602 ss << ' "' << input_schema->field (key_field_ids_[i])->name () << ' "' ;
624603 }
625604 ss << " ], " ;
626- AggregatesToString (&ss, *input_schema, aggs_, agg_src_field_ids_, owned_options_,
627- indent);
605+ AggregatesToString (&ss, *input_schema, aggs_, agg_src_field_ids_, indent);
628606 return ss.str ();
629607 }
630608
@@ -684,8 +662,6 @@ class GroupByNode : public ExecNode {
684662 const std::vector<int > agg_src_field_ids_;
685663 const std::vector<internal::Aggregate> aggs_;
686664 const std::vector<const HashAggregateKernel*> agg_kernels_;
687- // ARROW-13638: must hold owned copy of function options
688- const std::vector<std::unique_ptr<FunctionOptions>> owned_options_;
689665
690666 ThreadIndexer get_thread_index_;
691667 AtomicCounter input_counter_, output_counter_;
0 commit comments