duckdb 0.4.1-dev104.0 → 0.4.1-dev108.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/duckdb.cpp CHANGED
@@ -31066,7 +31066,8 @@ void RowOperations::DestroyStates(RowLayout &layout, Vector &addresses, idx_t co
31066
31066
 
31067
31067
  void RowOperations::UpdateStates(AggregateObject &aggr, Vector &addresses, DataChunk &payload, idx_t arg_idx,
31068
31068
  idx_t count) {
31069
- aggr.function.update(aggr.child_count == 0 ? nullptr : &payload.data[arg_idx], aggr.bind_data, aggr.child_count,
31069
+ AggregateInputData aggr_input_data(aggr.bind_data);
31070
+ aggr.function.update(aggr.child_count == 0 ? nullptr : &payload.data[arg_idx], aggr_input_data, aggr.child_count,
31070
31071
  addresses, count);
31071
31072
  }
31072
31073
 
@@ -31096,7 +31097,8 @@ void RowOperations::CombineStates(RowLayout &layout, Vector &sources, Vector &ta
31096
31097
  VectorOperations::AddInPlace(targets, layout.GetAggrOffset(), count);
31097
31098
  for (auto &aggr : layout.GetAggregates()) {
31098
31099
  D_ASSERT(aggr.function.combine);
31099
- aggr.function.combine(sources, targets, aggr.bind_data, count);
31100
+ AggregateInputData aggr_input_data(aggr.bind_data);
31101
+ aggr.function.combine(sources, targets, aggr_input_data, count);
31100
31102
 
31101
31103
  // Move to the next aggregate states
31102
31104
  VectorOperations::AddInPlace(sources, aggr.payload_size, count);
@@ -31112,7 +31114,8 @@ void RowOperations::FinalizeStates(RowLayout &layout, Vector &addresses, DataChu
31112
31114
  for (idx_t i = 0; i < aggregates.size(); i++) {
31113
31115
  auto &target = result.data[aggr_idx + i];
31114
31116
  auto &aggr = aggregates[i];
31115
- aggr.function.finalize(addresses, aggr.bind_data, target, result.size(), 0);
31117
+ AggregateInputData aggr_input_data(aggr.bind_data);
31118
+ aggr.function.finalize(addresses, aggr_input_data, target, result.size(), 0);
31116
31119
 
31117
31120
  // Move to the next aggregate state
31118
31121
  VectorOperations::AddInPlace(addresses, aggr.payload_size, result.size());
@@ -59646,9 +59649,9 @@ SinkResultType PhysicalSimpleAggregate::Sink(ExecutionContext &context, GlobalSi
59646
59649
  }
59647
59650
  }
59648
59651
 
59649
- aggregate.function.simple_update(payload_cnt == 0 ? nullptr : &payload_chunk.data[payload_idx],
59650
- aggregate.bind_info.get(), payload_cnt, sink.state.aggregates[aggr_idx].get(),
59651
- payload_chunk.size());
59652
+ AggregateInputData aggr_input_data(aggregate.bind_info.get());
59653
+ aggregate.function.simple_update(payload_cnt == 0 ? nullptr : &payload_chunk.data[payload_idx], aggr_input_data,
59654
+ payload_cnt, sink.state.aggregates[aggr_idx].get(), payload_chunk.size());
59652
59655
  payload_idx += payload_cnt;
59653
59656
  }
59654
59657
  return SinkResultType::NEED_MORE_INPUT;
@@ -59671,7 +59674,8 @@ void PhysicalSimpleAggregate::Combine(ExecutionContext &context, GlobalSinkState
59671
59674
  Vector source_state(Value::POINTER((uintptr_t)source.state.aggregates[aggr_idx].get()));
59672
59675
  Vector dest_state(Value::POINTER((uintptr_t)gstate.state.aggregates[aggr_idx].get()));
59673
59676
 
59674
- aggregate.function.combine(source_state, dest_state, aggregate.bind_info.get(), 1);
59677
+ AggregateInputData aggr_input_data(aggregate.bind_info.get());
59678
+ aggregate.function.combine(source_state, dest_state, aggr_input_data, 1);
59675
59679
  }
59676
59680
 
59677
59681
  auto &client_profiler = QueryProfiler::Get(context.client);
@@ -59718,7 +59722,8 @@ void PhysicalSimpleAggregate::GetData(ExecutionContext &context, DataChunk &chun
59718
59722
  auto &aggregate = (BoundAggregateExpression &)*aggregates[aggr_idx];
59719
59723
 
59720
59724
  Vector state_vector(Value::POINTER((uintptr_t)gstate.state.aggregates[aggr_idx].get()));
59721
- aggregate.function.finalize(state_vector, aggregate.bind_info.get(), chunk.data[aggr_idx], 1, 0);
59725
+ AggregateInputData aggr_input_data(aggregate.bind_info.get());
59726
+ aggregate.function.finalize(state_vector, aggr_input_data, chunk.data[aggr_idx], 1, 0);
59722
59727
  }
59723
59728
  state.finished = true;
59724
59729
  }
@@ -79249,8 +79254,9 @@ void RadixPartitionedHashTable::GetData(ExecutionContext &context, DataChunk &ch
79249
79254
  auto aggr_state = unique_ptr<data_t[]>(new data_t[aggr.function.state_size()]);
79250
79255
  aggr.function.initialize(aggr_state.get());
79251
79256
 
79257
+ AggregateInputData aggr_input_data(aggr.bind_info.get());
79252
79258
  Vector state_vector(Value::POINTER((uintptr_t)aggr_state.get()));
79253
- aggr.function.finalize(state_vector, aggr.bind_info.get(), chunk.data[null_groups.size() + i], 1, 0);
79259
+ aggr.function.finalize(state_vector, aggr_input_data, chunk.data[null_groups.size() + i], 1, 0);
79254
79260
  if (aggr.function.destructor) {
79255
79261
  aggr.function.destructor(state_vector, 1);
79256
79262
  }
@@ -79587,7 +79593,8 @@ void WindowSegmentTree::AggregateInit() {
79587
79593
  }
79588
79594
 
79589
79595
  void WindowSegmentTree::AggegateFinal(Vector &result, idx_t rid) {
79590
- aggregate.finalize(statev, bind_info, result, 1, rid);
79596
+ AggregateInputData aggr_input_data(bind_info);
79597
+ aggregate.finalize(statev, aggr_input_data, result, 1, rid);
79591
79598
 
79592
79599
  if (aggregate.destructor) {
79593
79600
  aggregate.destructor(statev, 1);
@@ -79654,7 +79661,8 @@ void WindowSegmentTree::WindowSegmentValue(idx_t l_idx, idx_t begin, idx_t end)
79654
79661
  Vector s(statep, 0);
79655
79662
  if (l_idx == 0) {
79656
79663
  ExtractFrame(begin, end);
79657
- aggregate.update(&inputs.data[0], bind_info, input_ref->ColumnCount(), s, inputs.size());
79664
+ AggregateInputData aggr_input_data(bind_info);
79665
+ aggregate.update(&inputs.data[0], aggr_input_data, input_ref->ColumnCount(), s, inputs.size());
79658
79666
  } else {
79659
79667
  inputs.Reset();
79660
79668
  inputs.SetCardinality(end - begin);
@@ -79667,7 +79675,8 @@ void WindowSegmentTree::WindowSegmentValue(idx_t l_idx, idx_t begin, idx_t end)
79667
79675
  pdata[i] = begin_ptr + i * state.size();
79668
79676
  }
79669
79677
  v.Verify(inputs.size());
79670
- aggregate.combine(v, s, bind_info, inputs.size());
79678
+ AggregateInputData aggr_input_data(bind_info);
79679
+ aggregate.combine(v, s, aggr_input_data, inputs.size());
79671
79680
  }
79672
79681
  }
79673
79682
 
@@ -79769,8 +79778,9 @@ void WindowSegmentTree::Compute(Vector &result, idx_t rid, idx_t begin, idx_t en
79769
79778
  active = FrameBounds(active_chunks.first * STANDARD_VECTOR_SIZE,
79770
79779
  MinValue((active_chunks.second + 1) * STANDARD_VECTOR_SIZE, coll.Count()));
79771
79780
 
79772
- aggregate.window(inputs.data.data(), filter_mask, bind_info, inputs.ColumnCount(), state.data(), frame, prev,
79773
- result, rid, active.first);
79781
+ AggregateInputData aggr_input_data(bind_info);
79782
+ aggregate.window(inputs.data.data(), filter_mask, aggr_input_data, inputs.ColumnCount(), state.data(), frame,
79783
+ prev, result, rid, active.first);
79774
79784
  return;
79775
79785
  }
79776
79786
 
@@ -80004,18 +80014,18 @@ struct BaseSumOperation {
80004
80014
  }
80005
80015
 
80006
80016
  template <class STATE, class OP>
80007
- static void Combine(const STATE &source, STATE *target, FunctionData *bind_data) {
80008
- STATEOP::template Combine<STATE>(source, target, bind_data);
80017
+ static void Combine(const STATE &source, STATE *target, AggregateInputData &aggr_input_data) {
80018
+ STATEOP::template Combine<STATE>(source, target, aggr_input_data);
80009
80019
  }
80010
80020
 
80011
80021
  template <class INPUT_TYPE, class STATE, class OP>
80012
- static void Operation(STATE *state, FunctionData *bind_data, INPUT_TYPE *input, ValidityMask &mask, idx_t idx) {
80022
+ static void Operation(STATE *state, AggregateInputData &, INPUT_TYPE *input, ValidityMask &mask, idx_t idx) {
80013
80023
  STATEOP::template AddValues<STATE>(state, 1);
80014
80024
  ADDOP::template AddNumber<STATE, INPUT_TYPE>(*state, input[idx]);
80015
80025
  }
80016
80026
 
80017
80027
  template <class INPUT_TYPE, class STATE, class OP>
80018
- static void ConstantOperation(STATE *state, FunctionData *bind_data, INPUT_TYPE *input, ValidityMask &mask,
80028
+ static void ConstantOperation(STATE *state, AggregateInputData &, INPUT_TYPE *input, ValidityMask &mask,
80019
80029
  idx_t count) {
80020
80030
  STATEOP::template AddValues<STATE>(state, count);
80021
80031
  ADDOP::template AddConstant<STATE, INPUT_TYPE>(*state, *input, count);
@@ -80090,7 +80100,7 @@ struct AverageSetOperation {
80090
80100
  state->Initialize();
80091
80101
  }
80092
80102
  template <class STATE>
80093
- static void Combine(const STATE &source, STATE *target, FunctionData *bind_data) {
80103
+ static void Combine(const STATE &source, STATE *target, AggregateInputData &) {
80094
80104
  target->Combine(source);
80095
80105
  }
80096
80106
  template <class STATE>
@@ -80111,12 +80121,12 @@ static T GetAverageDivident(uint64_t count, FunctionData *bind_data) {
80111
80121
 
80112
80122
  struct IntegerAverageOperation : public BaseSumOperation<AverageSetOperation, RegularAdd> {
80113
80123
  template <class T, class STATE>
80114
- static void Finalize(Vector &result, FunctionData *bind_data, STATE *state, T *target, ValidityMask &mask,
80115
- idx_t idx) {
80124
+ static void Finalize(Vector &result, AggregateInputData &aggr_input_data, STATE *state, T *target,
80125
+ ValidityMask &mask, idx_t idx) {
80116
80126
  if (state->count == 0) {
80117
80127
  mask.SetInvalid(idx);
80118
80128
  } else {
80119
- double divident = GetAverageDivident<double>(state->count, bind_data);
80129
+ double divident = GetAverageDivident<double>(state->count, aggr_input_data.bind_data);
80120
80130
  target[idx] = double(state->value) / divident;
80121
80131
  }
80122
80132
  }
@@ -80124,12 +80134,12 @@ struct IntegerAverageOperation : public BaseSumOperation<AverageSetOperation, Re
80124
80134
 
80125
80135
  struct IntegerAverageOperationHugeint : public BaseSumOperation<AverageSetOperation, HugeintAdd> {
80126
80136
  template <class T, class STATE>
80127
- static void Finalize(Vector &result, FunctionData *bind_data, STATE *state, T *target, ValidityMask &mask,
80128
- idx_t idx) {
80137
+ static void Finalize(Vector &result, AggregateInputData &aggr_input_data, STATE *state, T *target,
80138
+ ValidityMask &mask, idx_t idx) {
80129
80139
  if (state->count == 0) {
80130
80140
  mask.SetInvalid(idx);
80131
80141
  } else {
80132
- long double divident = GetAverageDivident<long double>(state->count, bind_data);
80142
+ long double divident = GetAverageDivident<long double>(state->count, aggr_input_data.bind_data);
80133
80143
  target[idx] = Hugeint::Cast<long double>(state->value) / divident;
80134
80144
  }
80135
80145
  }
@@ -80137,12 +80147,12 @@ struct IntegerAverageOperationHugeint : public BaseSumOperation<AverageSetOperat
80137
80147
 
80138
80148
  struct HugeintAverageOperation : public BaseSumOperation<AverageSetOperation, RegularAdd> {
80139
80149
  template <class T, class STATE>
80140
- static void Finalize(Vector &result, FunctionData *bind_data, STATE *state, T *target, ValidityMask &mask,
80141
- idx_t idx) {
80150
+ static void Finalize(Vector &result, AggregateInputData &aggr_input_data, STATE *state, T *target,
80151
+ ValidityMask &mask, idx_t idx) {
80142
80152
  if (state->count == 0) {
80143
80153
  mask.SetInvalid(idx);
80144
80154
  } else {
80145
- long double divident = GetAverageDivident<long double>(state->count, bind_data);
80155
+ long double divident = GetAverageDivident<long double>(state->count, aggr_input_data.bind_data);
80146
80156
  target[idx] = Hugeint::Cast<long double>(state->value) / divident;
80147
80157
  }
80148
80158
  }
@@ -80150,7 +80160,7 @@ struct HugeintAverageOperation : public BaseSumOperation<AverageSetOperation, Re
80150
80160
 
80151
80161
  struct NumericAverageOperation : public BaseSumOperation<AverageSetOperation, RegularAdd> {
80152
80162
  template <class T, class STATE>
80153
- static void Finalize(Vector &result, FunctionData *, STATE *state, T *target, ValidityMask &mask, idx_t idx) {
80163
+ static void Finalize(Vector &result, AggregateInputData &, STATE *state, T *target, ValidityMask &mask, idx_t idx) {
80154
80164
  if (state->count == 0) {
80155
80165
  mask.SetInvalid(idx);
80156
80166
  } else {
@@ -80164,7 +80174,7 @@ struct NumericAverageOperation : public BaseSumOperation<AverageSetOperation, Re
80164
80174
 
80165
80175
  struct KahanAverageOperation : public BaseSumOperation<AverageSetOperation, KahanAdd> {
80166
80176
  template <class T, class STATE>
80167
- static void Finalize(Vector &result, FunctionData *, STATE *state, T *target, ValidityMask &mask, idx_t idx) {
80177
+ static void Finalize(Vector &result, AggregateInputData &, STATE *state, T *target, ValidityMask &mask, idx_t idx) {
80168
80178
  if (state->count == 0) {
80169
80179
  mask.SetInvalid(idx);
80170
80180
  } else {
@@ -80266,7 +80276,7 @@ struct CovarOperation {
80266
80276
  }
80267
80277
 
80268
80278
  template <class A_TYPE, class B_TYPE, class STATE, class OP>
80269
- static void Operation(STATE *state, FunctionData *bind_data, A_TYPE *x_data, B_TYPE *y_data, ValidityMask &amask,
80279
+ static void Operation(STATE *state, AggregateInputData &, A_TYPE *x_data, B_TYPE *y_data, ValidityMask &amask,
80270
80280
  ValidityMask &bmask, idx_t xidx, idx_t yidx) {
80271
80281
  // update running mean and d^2
80272
80282
  const uint64_t n = ++(state->count);
@@ -80287,7 +80297,7 @@ struct CovarOperation {
80287
80297
  }
80288
80298
 
80289
80299
  template <class STATE, class OP>
80290
- static void Combine(const STATE &source, STATE *target, FunctionData *bind_data) {
80300
+ static void Combine(const STATE &source, STATE *target, AggregateInputData &) {
80291
80301
  if (target->count == 0) {
80292
80302
  *target = source;
80293
80303
  } else if (source.count > 0) {
@@ -80313,7 +80323,7 @@ struct CovarOperation {
80313
80323
 
80314
80324
  struct CovarPopOperation : public CovarOperation {
80315
80325
  template <class T, class STATE>
80316
- static void Finalize(Vector &result, FunctionData *, STATE *state, T *target, ValidityMask &mask, idx_t idx) {
80326
+ static void Finalize(Vector &result, AggregateInputData &, STATE *state, T *target, ValidityMask &mask, idx_t idx) {
80317
80327
  if (state->count == 0) {
80318
80328
  mask.SetInvalid(idx);
80319
80329
  } else {
@@ -80324,7 +80334,7 @@ struct CovarPopOperation : public CovarOperation {
80324
80334
 
80325
80335
  struct CovarSampOperation : public CovarOperation {
80326
80336
  template <class T, class STATE>
80327
- static void Finalize(Vector &result, FunctionData *, STATE *state, T *target, ValidityMask &mask, idx_t idx) {
80337
+ static void Finalize(Vector &result, AggregateInputData &, STATE *state, T *target, ValidityMask &mask, idx_t idx) {
80328
80338
  if ((state->count) < 2) {
80329
80339
  mask.SetInvalid(idx);
80330
80340
  } else {
@@ -80366,8 +80376,7 @@ struct STDDevBaseOperation {
80366
80376
  }
80367
80377
 
80368
80378
  template <class INPUT_TYPE, class STATE, class OP>
80369
- static void Operation(STATE *state, FunctionData *bind_data, INPUT_TYPE *input_data, ValidityMask &mask,
80370
- idx_t idx) {
80379
+ static void Operation(STATE *state, AggregateInputData &, INPUT_TYPE *input_data, ValidityMask &mask, idx_t idx) {
80371
80380
  // update running mean and d^2
80372
80381
  state->count++;
80373
80382
  const double input = input_data[idx];
@@ -80381,15 +80390,15 @@ struct STDDevBaseOperation {
80381
80390
  }
80382
80391
 
80383
80392
  template <class INPUT_TYPE, class STATE, class OP>
80384
- static void ConstantOperation(STATE *state, FunctionData *bind_data, INPUT_TYPE *input_data, ValidityMask &mask,
80385
- idx_t count) {
80393
+ static void ConstantOperation(STATE *state, AggregateInputData &aggr_input_data, INPUT_TYPE *input_data,
80394
+ ValidityMask &mask, idx_t count) {
80386
80395
  for (idx_t i = 0; i < count; i++) {
80387
- Operation<INPUT_TYPE, STATE, OP>(state, bind_data, input_data, mask, 0);
80396
+ Operation<INPUT_TYPE, STATE, OP>(state, aggr_input_data, input_data, mask, 0);
80388
80397
  }
80389
80398
  }
80390
80399
 
80391
80400
  template <class STATE, class OP>
80392
- static void Combine(const STATE &source, STATE *target, FunctionData *bind_data) {
80401
+ static void Combine(const STATE &source, STATE *target, AggregateInputData &) {
80393
80402
  if (target->count == 0) {
80394
80403
  *target = source;
80395
80404
  } else if (source.count > 0) {
@@ -80410,7 +80419,7 @@ struct STDDevBaseOperation {
80410
80419
 
80411
80420
  struct VarSampOperation : public STDDevBaseOperation {
80412
80421
  template <class T, class STATE>
80413
- static void Finalize(Vector &result, FunctionData *, STATE *state, T *target, ValidityMask &mask, idx_t idx) {
80422
+ static void Finalize(Vector &result, AggregateInputData &, STATE *state, T *target, ValidityMask &mask, idx_t idx) {
80414
80423
  if (state->count <= 1) {
80415
80424
  mask.SetInvalid(idx);
80416
80425
  } else {
@@ -80424,7 +80433,7 @@ struct VarSampOperation : public STDDevBaseOperation {
80424
80433
 
80425
80434
  struct VarPopOperation : public STDDevBaseOperation {
80426
80435
  template <class T, class STATE>
80427
- static void Finalize(Vector &result, FunctionData *, STATE *state, T *target, ValidityMask &mask, idx_t idx) {
80436
+ static void Finalize(Vector &result, AggregateInputData &, STATE *state, T *target, ValidityMask &mask, idx_t idx) {
80428
80437
  if (state->count == 0) {
80429
80438
  mask.SetInvalid(idx);
80430
80439
  } else {
@@ -80438,7 +80447,7 @@ struct VarPopOperation : public STDDevBaseOperation {
80438
80447
 
80439
80448
  struct STDDevSampOperation : public STDDevBaseOperation {
80440
80449
  template <class T, class STATE>
80441
- static void Finalize(Vector &result, FunctionData *, STATE *state, T *target, ValidityMask &mask, idx_t idx) {
80450
+ static void Finalize(Vector &result, AggregateInputData &, STATE *state, T *target, ValidityMask &mask, idx_t idx) {
80442
80451
  if (state->count <= 1) {
80443
80452
  mask.SetInvalid(idx);
80444
80453
  } else {
@@ -80452,7 +80461,7 @@ struct STDDevSampOperation : public STDDevBaseOperation {
80452
80461
 
80453
80462
  struct STDDevPopOperation : public STDDevBaseOperation {
80454
80463
  template <class T, class STATE>
80455
- static void Finalize(Vector &result, FunctionData *, STATE *state, T *target, ValidityMask &mask, idx_t idx) {
80464
+ static void Finalize(Vector &result, AggregateInputData &, STATE *state, T *target, ValidityMask &mask, idx_t idx) {
80456
80465
  if (state->count == 0) {
80457
80466
  mask.SetInvalid(idx);
80458
80467
  } else {
@@ -80466,7 +80475,7 @@ struct STDDevPopOperation : public STDDevBaseOperation {
80466
80475
 
80467
80476
  struct StandardErrorOfTheMeanOperation : public STDDevBaseOperation {
80468
80477
  template <class T, class STATE>
80469
- static void Finalize(Vector &result, FunctionData *, STATE *state, T *target, ValidityMask &mask, idx_t idx) {
80478
+ static void Finalize(Vector &result, AggregateInputData &, STATE *state, T *target, ValidityMask &mask, idx_t idx) {
80470
80479
  if (state->count == 0) {
80471
80480
  mask.SetInvalid(idx);
80472
80481
  } else {
@@ -80513,23 +80522,25 @@ struct CorrOperation {
80513
80522
  }
80514
80523
 
80515
80524
  template <class A_TYPE, class B_TYPE, class STATE, class OP>
80516
- static void Operation(STATE *state, FunctionData *bind_data, A_TYPE *x_data, B_TYPE *y_data, ValidityMask &amask,
80517
- ValidityMask &bmask, idx_t xidx, idx_t yidx) {
80518
- CovarOperation::Operation<A_TYPE, B_TYPE, CovarState, OP>(&state->cov_pop, bind_data, x_data, y_data, amask,
80519
- bmask, xidx, yidx);
80520
- STDDevBaseOperation::Operation<A_TYPE, StddevState, OP>(&state->dev_pop_x, bind_data, x_data, amask, xidx);
80521
- STDDevBaseOperation::Operation<B_TYPE, StddevState, OP>(&state->dev_pop_y, bind_data, y_data, bmask, yidx);
80525
+ static void Operation(STATE *state, AggregateInputData &aggr_input_data, A_TYPE *x_data, B_TYPE *y_data,
80526
+ ValidityMask &amask, ValidityMask &bmask, idx_t xidx, idx_t yidx) {
80527
+ CovarOperation::Operation<A_TYPE, B_TYPE, CovarState, OP>(&state->cov_pop, aggr_input_data, x_data, y_data,
80528
+ amask, bmask, xidx, yidx);
80529
+ STDDevBaseOperation::Operation<A_TYPE, StddevState, OP>(&state->dev_pop_x, aggr_input_data, x_data, amask,
80530
+ xidx);
80531
+ STDDevBaseOperation::Operation<B_TYPE, StddevState, OP>(&state->dev_pop_y, aggr_input_data, y_data, bmask,
80532
+ yidx);
80522
80533
  }
80523
80534
 
80524
80535
  template <class STATE, class OP>
80525
- static void Combine(const STATE &source, STATE *target, FunctionData *bind_data) {
80526
- CovarOperation::Combine<CovarState, OP>(source.cov_pop, &target->cov_pop, bind_data);
80527
- STDDevBaseOperation::Combine<StddevState, OP>(source.dev_pop_x, &target->dev_pop_x, bind_data);
80528
- STDDevBaseOperation::Combine<StddevState, OP>(source.dev_pop_y, &target->dev_pop_y, bind_data);
80536
+ static void Combine(const STATE &source, STATE *target, AggregateInputData &aggr_input_data) {
80537
+ CovarOperation::Combine<CovarState, OP>(source.cov_pop, &target->cov_pop, aggr_input_data);
80538
+ STDDevBaseOperation::Combine<StddevState, OP>(source.dev_pop_x, &target->dev_pop_x, aggr_input_data);
80539
+ STDDevBaseOperation::Combine<StddevState, OP>(source.dev_pop_y, &target->dev_pop_y, aggr_input_data);
80529
80540
  }
80530
80541
 
80531
80542
  template <class T, class STATE>
80532
- static void Finalize(Vector &result, FunctionData *, STATE *state, T *target, ValidityMask &mask, idx_t idx) {
80543
+ static void Finalize(Vector &result, AggregateInputData &, STATE *state, T *target, ValidityMask &mask, idx_t idx) {
80533
80544
  if (state->cov_pop.count == 0 || state->dev_pop_x.count == 0 || state->dev_pop_y.count == 0) {
80534
80545
  mask.SetInvalid(idx);
80535
80546
  } else {
@@ -80688,7 +80699,7 @@ struct ApproxCountDistinctFunction {
80688
80699
  }
80689
80700
 
80690
80701
  template <class STATE, class OP>
80691
- static void Combine(const STATE &source, STATE *target, FunctionData *bind_data) {
80702
+ static void Combine(const STATE &source, STATE *target, AggregateInputData &) {
80692
80703
  if (!source.log) {
80693
80704
  return;
80694
80705
  }
@@ -80703,7 +80714,7 @@ struct ApproxCountDistinctFunction {
80703
80714
  }
80704
80715
 
80705
80716
  template <class T, class STATE>
80706
- static void Finalize(Vector &result, FunctionData *, STATE *state, T *target, ValidityMask &mask, idx_t idx) {
80717
+ static void Finalize(Vector &result, AggregateInputData &, STATE *state, T *target, ValidityMask &mask, idx_t idx) {
80707
80718
  if (state->log) {
80708
80719
  target[idx] = state->log->Count();
80709
80720
  } else {
@@ -80722,7 +80733,7 @@ struct ApproxCountDistinctFunction {
80722
80733
  }
80723
80734
  };
80724
80735
 
80725
- static void ApproxCountDistinctSimpleUpdateFunction(Vector inputs[], FunctionData *bind_data, idx_t input_count,
80736
+ static void ApproxCountDistinctSimpleUpdateFunction(Vector inputs[], AggregateInputData &, idx_t input_count,
80726
80737
  data_ptr_t state, idx_t count) {
80727
80738
  D_ASSERT(input_count == 1);
80728
80739
 
@@ -80741,7 +80752,7 @@ static void ApproxCountDistinctSimpleUpdateFunction(Vector inputs[], FunctionDat
80741
80752
  agg_state->log->AddToLog(vdata, count, indices, counts);
80742
80753
  }
80743
80754
 
80744
- static void ApproxCountDistinctUpdateFunction(Vector inputs[], FunctionData *bind_data, idx_t input_count,
80755
+ static void ApproxCountDistinctUpdateFunction(Vector inputs[], AggregateInputData &, idx_t input_count,
80745
80756
  Vector &state_vector, idx_t count) {
80746
80757
  D_ASSERT(input_count == 1);
80747
80758
 
@@ -80861,7 +80872,7 @@ struct ArgMinMaxBase {
80861
80872
  }
80862
80873
 
80863
80874
  template <class A_TYPE, class B_TYPE, class STATE, class OP>
80864
- static void Operation(STATE *state, FunctionData *bind_data, A_TYPE *x_data, B_TYPE *y_data, ValidityMask &amask,
80875
+ static void Operation(STATE *state, AggregateInputData &, A_TYPE *x_data, B_TYPE *y_data, ValidityMask &amask,
80865
80876
  ValidityMask &bmask, idx_t xidx, idx_t yidx) {
80866
80877
  if (!state->is_initialized) {
80867
80878
  ArgMinMaxAssignValue<A_TYPE>(state->arg, x_data[xidx], false);
@@ -80881,7 +80892,7 @@ struct ArgMinMaxBase {
80881
80892
  }
80882
80893
 
80883
80894
  template <class STATE, class OP>
80884
- static void Combine(const STATE &source, STATE *target, FunctionData *bind_data) {
80895
+ static void Combine(const STATE &source, STATE *target, AggregateInputData &) {
80885
80896
  if (!source.is_initialized) {
80886
80897
  return;
80887
80898
  }
@@ -80900,7 +80911,7 @@ struct ArgMinMaxBase {
80900
80911
  template <class COMPARATOR>
80901
80912
  struct StringArgMinMax : public ArgMinMaxBase<COMPARATOR> {
80902
80913
  template <class T, class STATE>
80903
- static void Finalize(Vector &result, FunctionData *, STATE *state, T *target, ValidityMask &mask, idx_t idx) {
80914
+ static void Finalize(Vector &result, AggregateInputData &, STATE *state, T *target, ValidityMask &mask, idx_t idx) {
80904
80915
  if (!state->is_initialized) {
80905
80916
  mask.SetInvalid(idx);
80906
80917
  } else {
@@ -80912,7 +80923,7 @@ struct StringArgMinMax : public ArgMinMaxBase<COMPARATOR> {
80912
80923
  template <class COMPARATOR>
80913
80924
  struct NumericArgMinMax : public ArgMinMaxBase<COMPARATOR> {
80914
80925
  template <class T, class STATE>
80915
- static void Finalize(Vector &result, FunctionData *, STATE *state, T *target, ValidityMask &mask, idx_t idx) {
80926
+ static void Finalize(Vector &result, AggregateInputData &, STATE *state, T *target, ValidityMask &mask, idx_t idx) {
80916
80927
  if (!state->is_initialized) {
80917
80928
  mask.SetInvalid(idx);
80918
80929
  } else {
@@ -81051,7 +81062,7 @@ struct BitAndOperation {
81051
81062
  }
81052
81063
 
81053
81064
  template <class INPUT_TYPE, class STATE, class OP>
81054
- static void Operation(STATE *state, FunctionData *bind_data, INPUT_TYPE *input, ValidityMask &mask, idx_t idx) {
81065
+ static void Operation(STATE *state, AggregateInputData &, INPUT_TYPE *input, ValidityMask &mask, idx_t idx) {
81055
81066
  if (!state->is_set) {
81056
81067
  state->is_set = true;
81057
81068
  state->value = input[idx];
@@ -81061,14 +81072,14 @@ struct BitAndOperation {
81061
81072
  }
81062
81073
 
81063
81074
  template <class INPUT_TYPE, class STATE, class OP>
81064
- static void ConstantOperation(STATE *state, FunctionData *bind_data, INPUT_TYPE *input, ValidityMask &mask,
81065
- idx_t count) {
81075
+ static void ConstantOperation(STATE *state, AggregateInputData &aggr_input_data, INPUT_TYPE *input,
81076
+ ValidityMask &mask, idx_t count) {
81066
81077
  // count is irrelevant
81067
- Operation<INPUT_TYPE, STATE, OP>(state, bind_data, input, mask, 0);
81078
+ Operation<INPUT_TYPE, STATE, OP>(state, aggr_input_data, input, mask, 0);
81068
81079
  }
81069
81080
 
81070
81081
  template <class T, class STATE>
81071
- static void Finalize(Vector &result, FunctionData *, STATE *state, T *target, ValidityMask &mask, idx_t idx) {
81082
+ static void Finalize(Vector &result, AggregateInputData &, STATE *state, T *target, ValidityMask &mask, idx_t idx) {
81072
81083
  if (!state->is_set) {
81073
81084
  mask.SetInvalid(idx);
81074
81085
  } else {
@@ -81077,7 +81088,7 @@ struct BitAndOperation {
81077
81088
  }
81078
81089
 
81079
81090
  template <class STATE, class OP>
81080
- static void Combine(const STATE &source, STATE *target, FunctionData *bind_data) {
81091
+ static void Combine(const STATE &source, STATE *target, AggregateInputData &) {
81081
81092
  if (!source.is_set) {
81082
81093
  // source is NULL, nothing to do.
81083
81094
  return;
@@ -81111,7 +81122,7 @@ struct BitOrOperation {
81111
81122
  }
81112
81123
 
81113
81124
  template <class INPUT_TYPE, class STATE, class OP>
81114
- static void Operation(STATE *state, FunctionData *bind_data, INPUT_TYPE *input, ValidityMask &mask, idx_t idx) {
81125
+ static void Operation(STATE *state, AggregateInputData &, INPUT_TYPE *input, ValidityMask &mask, idx_t idx) {
81115
81126
  if (!state->is_set) {
81116
81127
  state->is_set = true;
81117
81128
  state->value = input[idx];
@@ -81121,14 +81132,14 @@ struct BitOrOperation {
81121
81132
  }
81122
81133
 
81123
81134
  template <class INPUT_TYPE, class STATE, class OP>
81124
- static void ConstantOperation(STATE *state, FunctionData *bind_data, INPUT_TYPE *input, ValidityMask &mask,
81125
- idx_t count) {
81135
+ static void ConstantOperation(STATE *state, AggregateInputData &aggr_input_data, INPUT_TYPE *input,
81136
+ ValidityMask &mask, idx_t count) {
81126
81137
  // count is irrelevant
81127
- Operation<INPUT_TYPE, STATE, OP>(state, bind_data, input, mask, 0);
81138
+ Operation<INPUT_TYPE, STATE, OP>(state, aggr_input_data, input, mask, 0);
81128
81139
  }
81129
81140
 
81130
81141
  template <class T, class STATE>
81131
- static void Finalize(Vector &result, FunctionData *, STATE *state, T *target, ValidityMask &mask, idx_t idx) {
81142
+ static void Finalize(Vector &result, AggregateInputData &, STATE *state, T *target, ValidityMask &mask, idx_t idx) {
81132
81143
  if (!state->is_set) {
81133
81144
  mask.SetInvalid(idx);
81134
81145
  } else {
@@ -81137,7 +81148,7 @@ struct BitOrOperation {
81137
81148
  }
81138
81149
 
81139
81150
  template <class STATE, class OP>
81140
- static void Combine(const STATE &source, STATE *target, FunctionData *bind_data) {
81151
+ static void Combine(const STATE &source, STATE *target, AggregateInputData &) {
81141
81152
  if (!source.is_set) {
81142
81153
  // source is NULL, nothing to do.
81143
81154
  return;
@@ -81171,7 +81182,7 @@ struct BitXorOperation {
81171
81182
  }
81172
81183
 
81173
81184
  template <class INPUT_TYPE, class STATE, class OP>
81174
- static void Operation(STATE *state, FunctionData *bind_data, INPUT_TYPE *input, ValidityMask &mask, idx_t idx) {
81185
+ static void Operation(STATE *state, AggregateInputData &, INPUT_TYPE *input, ValidityMask &mask, idx_t idx) {
81175
81186
  if (!state->is_set) {
81176
81187
  state->is_set = true;
81177
81188
  state->value = input[idx];
@@ -81181,14 +81192,14 @@ struct BitXorOperation {
81181
81192
  }
81182
81193
 
81183
81194
  template <class INPUT_TYPE, class STATE, class OP>
81184
- static void ConstantOperation(STATE *state, FunctionData *bind_data, INPUT_TYPE *input, ValidityMask &mask,
81185
- idx_t count) {
81195
+ static void ConstantOperation(STATE *state, AggregateInputData &aggr_input_data, INPUT_TYPE *input,
81196
+ ValidityMask &mask, idx_t count) {
81186
81197
  // count is irrelevant
81187
- Operation<INPUT_TYPE, STATE, OP>(state, bind_data, input, mask, 0);
81198
+ Operation<INPUT_TYPE, STATE, OP>(state, aggr_input_data, input, mask, 0);
81188
81199
  }
81189
81200
 
81190
81201
  template <class T, class STATE>
81191
- static void Finalize(Vector &result, FunctionData *, STATE *state, T *target, ValidityMask &mask, idx_t idx) {
81202
+ static void Finalize(Vector &result, AggregateInputData &, STATE *state, T *target, ValidityMask &mask, idx_t idx) {
81192
81203
  if (!state->is_set) {
81193
81204
  mask.SetInvalid(idx);
81194
81205
  } else {
@@ -81197,7 +81208,7 @@ struct BitXorOperation {
81197
81208
  }
81198
81209
 
81199
81210
  template <class STATE, class OP>
81200
- static void Combine(const STATE &source, STATE *target, FunctionData *bind_data) {
81211
+ static void Combine(const STATE &source, STATE *target, AggregateInputData &) {
81201
81212
  if (!source.is_set) {
81202
81213
  // source is NULL, nothing to do.
81203
81214
  return;
@@ -81245,13 +81256,13 @@ struct BoolAndFunFunction {
81245
81256
  }
81246
81257
 
81247
81258
  template <class STATE, class OP>
81248
- static void Combine(const STATE &source, STATE *target, FunctionData *bind_data) {
81259
+ static void Combine(const STATE &source, STATE *target, AggregateInputData &) {
81249
81260
  target->val = target->val && source.val;
81250
81261
  target->empty = target->empty && source.empty;
81251
81262
  }
81252
81263
 
81253
81264
  template <class T, class STATE>
81254
- static void Finalize(Vector &result, FunctionData *, STATE *state, T *target, ValidityMask &mask, idx_t idx) {
81265
+ static void Finalize(Vector &result, AggregateInputData &, STATE *state, T *target, ValidityMask &mask, idx_t idx) {
81255
81266
  if (state->empty) {
81256
81267
  mask.SetInvalid(idx);
81257
81268
  return;
@@ -81260,16 +81271,16 @@ struct BoolAndFunFunction {
81260
81271
  }
81261
81272
 
81262
81273
  template <class INPUT_TYPE, class STATE, class OP>
81263
- static void Operation(STATE *state, FunctionData *bind_data, INPUT_TYPE *input, ValidityMask &mask, idx_t idx) {
81274
+ static void Operation(STATE *state, AggregateInputData &, INPUT_TYPE *input, ValidityMask &mask, idx_t idx) {
81264
81275
  state->empty = false;
81265
81276
  state->val = input[idx] && state->val;
81266
81277
  }
81267
81278
 
81268
81279
  template <class INPUT_TYPE, class STATE, class OP>
81269
- static void ConstantOperation(STATE *state, FunctionData *bind_data, INPUT_TYPE *input, ValidityMask &mask,
81270
- idx_t count) {
81280
+ static void ConstantOperation(STATE *state, AggregateInputData &aggr_input_data, INPUT_TYPE *input,
81281
+ ValidityMask &mask, idx_t count) {
81271
81282
  for (idx_t i = 0; i < count; i++) {
81272
- Operation<INPUT_TYPE, STATE, OP>(state, bind_data, input, mask, 0);
81283
+ Operation<INPUT_TYPE, STATE, OP>(state, aggr_input_data, input, mask, 0);
81273
81284
  }
81274
81285
  }
81275
81286
  static bool IgnoreNull() {
@@ -81285,13 +81296,13 @@ struct BoolOrFunFunction {
81285
81296
  }
81286
81297
 
81287
81298
  template <class STATE, class OP>
81288
- static void Combine(const STATE &source, STATE *target, FunctionData *bind_data) {
81299
+ static void Combine(const STATE &source, STATE *target, AggregateInputData &) {
81289
81300
  target->val = target->val || source.val;
81290
81301
  target->empty = target->empty && source.empty;
81291
81302
  }
81292
81303
 
81293
81304
  template <class T, class STATE>
81294
- static void Finalize(Vector &result, FunctionData *, STATE *state, T *target, ValidityMask &mask, idx_t idx) {
81305
+ static void Finalize(Vector &result, AggregateInputData &, STATE *state, T *target, ValidityMask &mask, idx_t idx) {
81295
81306
  if (state->empty) {
81296
81307
  mask.SetInvalid(idx);
81297
81308
  return;
@@ -81299,16 +81310,16 @@ struct BoolOrFunFunction {
81299
81310
  target[idx] = state->val;
81300
81311
  }
81301
81312
  template <class INPUT_TYPE, class STATE, class OP>
81302
- static void Operation(STATE *state, FunctionData *bind_data, INPUT_TYPE *input, ValidityMask &mask, idx_t idx) {
81313
+ static void Operation(STATE *state, AggregateInputData &, INPUT_TYPE *input, ValidityMask &mask, idx_t idx) {
81303
81314
  state->empty = false;
81304
81315
  state->val = input[idx] || state->val;
81305
81316
  }
81306
81317
 
81307
81318
  template <class INPUT_TYPE, class STATE, class OP>
81308
- static void ConstantOperation(STATE *state, FunctionData *bind_data, INPUT_TYPE *input, ValidityMask &mask,
81309
- idx_t count) {
81319
+ static void ConstantOperation(STATE *state, AggregateInputData &aggr_input_data, INPUT_TYPE *input,
81320
+ ValidityMask &mask, idx_t count) {
81310
81321
  for (idx_t i = 0; i < count; i++) {
81311
- Operation<INPUT_TYPE, STATE, OP>(state, bind_data, input, mask, 0);
81322
+ Operation<INPUT_TYPE, STATE, OP>(state, aggr_input_data, input, mask, 0);
81312
81323
  }
81313
81324
  }
81314
81325
 
@@ -81361,36 +81372,36 @@ struct BaseCountFunction {
81361
81372
  }
81362
81373
 
81363
81374
  template <class STATE, class OP>
81364
- static void Combine(const STATE &source, STATE *target, FunctionData *bind_data) {
81375
+ static void Combine(const STATE &source, STATE *target, AggregateInputData &) {
81365
81376
  *target += source;
81366
81377
  }
81367
81378
 
81368
81379
  template <class T, class STATE>
81369
- static void Finalize(Vector &result, FunctionData *, STATE *state, T *target, ValidityMask &mask, idx_t idx) {
81380
+ static void Finalize(Vector &result, AggregateInputData &, STATE *state, T *target, ValidityMask &mask, idx_t idx) {
81370
81381
  target[idx] = *state;
81371
81382
  }
81372
81383
  };
81373
81384
 
81374
81385
  struct CountStarFunction : public BaseCountFunction {
81375
81386
  template <class STATE, class OP>
81376
- static void Operation(STATE *state, FunctionData *bind_data, idx_t idx) {
81387
+ static void Operation(STATE *state, AggregateInputData &, idx_t idx) {
81377
81388
  *state += 1;
81378
81389
  }
81379
81390
 
81380
81391
  template <class STATE, class OP>
81381
- static void ConstantOperation(STATE *state, FunctionData *bind_data, idx_t count) {
81392
+ static void ConstantOperation(STATE *state, AggregateInputData &, idx_t count) {
81382
81393
  *state += count;
81383
81394
  }
81384
81395
  };
81385
81396
 
81386
81397
  struct CountFunction : public BaseCountFunction {
81387
81398
  template <class INPUT_TYPE, class STATE, class OP>
81388
- static void Operation(STATE *state, FunctionData *bind_data, INPUT_TYPE *input, ValidityMask &mask, idx_t idx) {
81399
+ static void Operation(STATE *state, AggregateInputData &, INPUT_TYPE *input, ValidityMask &mask, idx_t idx) {
81389
81400
  *state += 1;
81390
81401
  }
81391
81402
 
81392
81403
  template <class INPUT_TYPE, class STATE, class OP>
81393
- static void ConstantOperation(STATE *state, FunctionData *bind_data, INPUT_TYPE *input, ValidityMask &mask,
81404
+ static void ConstantOperation(STATE *state, AggregateInputData &, INPUT_TYPE *input, ValidityMask &mask,
81394
81405
  idx_t count) {
81395
81406
  *state += count;
81396
81407
  }
@@ -81478,7 +81489,7 @@ struct EntropyFunctionBase {
81478
81489
  }
81479
81490
 
81480
81491
  template <class STATE, class OP>
81481
- static void Combine(const STATE &source, STATE *target, FunctionData *bind_data) {
81492
+ static void Combine(const STATE &source, STATE *target, AggregateInputData &) {
81482
81493
  if (!source.distinct) {
81483
81494
  return;
81484
81495
  }
@@ -81494,7 +81505,7 @@ struct EntropyFunctionBase {
81494
81505
  }
81495
81506
 
81496
81507
  template <class T, class STATE>
81497
- static void Finalize(Vector &result, FunctionData *, STATE *state, T *target, ValidityMask &mask, idx_t idx) {
81508
+ static void Finalize(Vector &result, AggregateInputData &, STATE *state, T *target, ValidityMask &mask, idx_t idx) {
81498
81509
  double count = state->count;
81499
81510
  if (state->distinct) {
81500
81511
  double entropy = 0;
@@ -81520,7 +81531,7 @@ struct EntropyFunctionBase {
81520
81531
 
81521
81532
  struct EntropyFunction : EntropyFunctionBase {
81522
81533
  template <class INPUT_TYPE, class STATE, class OP>
81523
- static void Operation(STATE *state, FunctionData *bind_data, INPUT_TYPE *input, ValidityMask &mask, idx_t idx) {
81534
+ static void Operation(STATE *state, AggregateInputData &, INPUT_TYPE *input, ValidityMask &mask, idx_t idx) {
81524
81535
  if (!state->distinct) {
81525
81536
  state->distinct = new unordered_map<INPUT_TYPE, idx_t>();
81526
81537
  }
@@ -81528,17 +81539,17 @@ struct EntropyFunction : EntropyFunctionBase {
81528
81539
  state->count++;
81529
81540
  }
81530
81541
  template <class INPUT_TYPE, class STATE, class OP>
81531
- static void ConstantOperation(STATE *state, FunctionData *bind_data, INPUT_TYPE *input, ValidityMask &mask,
81532
- idx_t count) {
81542
+ static void ConstantOperation(STATE *state, AggregateInputData &aggr_input_data, INPUT_TYPE *input,
81543
+ ValidityMask &mask, idx_t count) {
81533
81544
  for (idx_t i = 0; i < count; i++) {
81534
- Operation<INPUT_TYPE, STATE, OP>(state, bind_data, input, mask, 0);
81545
+ Operation<INPUT_TYPE, STATE, OP>(state, aggr_input_data, input, mask, 0);
81535
81546
  }
81536
81547
  }
81537
81548
  };
81538
81549
 
81539
81550
  struct EntropyFunctionString : EntropyFunctionBase {
81540
81551
  template <class INPUT_TYPE, class STATE, class OP>
81541
- static void Operation(STATE *state, FunctionData *bind_data, INPUT_TYPE *input, ValidityMask &mask, idx_t idx) {
81552
+ static void Operation(STATE *state, AggregateInputData &, INPUT_TYPE *input, ValidityMask &mask, idx_t idx) {
81542
81553
  if (!state->distinct) {
81543
81554
  state->distinct = new unordered_map<string, idx_t>();
81544
81555
  }
@@ -81548,10 +81559,10 @@ struct EntropyFunctionString : EntropyFunctionBase {
81548
81559
  }
81549
81560
 
81550
81561
  template <class INPUT_TYPE, class STATE, class OP>
81551
- static void ConstantOperation(STATE *state, FunctionData *bind_data, INPUT_TYPE *input, ValidityMask &mask,
81552
- idx_t count) {
81562
+ static void ConstantOperation(STATE *state, AggregateInputData &aggr_input_data, INPUT_TYPE *input,
81563
+ ValidityMask &mask, idx_t count) {
81553
81564
  for (idx_t i = 0; i < count; i++) {
81554
- Operation<INPUT_TYPE, STATE, OP>(state, bind_data, input, mask, 0);
81565
+ Operation<INPUT_TYPE, STATE, OP>(state, aggr_input_data, input, mask, 0);
81555
81566
  }
81556
81567
  }
81557
81568
  };
@@ -81644,7 +81655,7 @@ struct FirstFunctionBase {
81644
81655
  template <bool LAST>
81645
81656
  struct FirstFunction : public FirstFunctionBase {
81646
81657
  template <class INPUT_TYPE, class STATE, class OP>
81647
- static void Operation(STATE *state, FunctionData *bind_data, INPUT_TYPE *input, ValidityMask &mask, idx_t idx) {
81658
+ static void Operation(STATE *state, AggregateInputData &, INPUT_TYPE *input, ValidityMask &mask, idx_t idx) {
81648
81659
  if (LAST || !state->is_set) {
81649
81660
  state->is_set = true;
81650
81661
  if (!mask.RowIsValid(idx)) {
@@ -81657,20 +81668,20 @@ struct FirstFunction : public FirstFunctionBase {
81657
81668
  }
81658
81669
 
81659
81670
  template <class INPUT_TYPE, class STATE, class OP>
81660
- static void ConstantOperation(STATE *state, FunctionData *bind_data, INPUT_TYPE *input, ValidityMask &mask,
81661
- idx_t count) {
81662
- Operation<INPUT_TYPE, STATE, OP>(state, bind_data, input, mask, 0);
81671
+ static void ConstantOperation(STATE *state, AggregateInputData &aggr_input_data, INPUT_TYPE *input,
81672
+ ValidityMask &mask, idx_t count) {
81673
+ Operation<INPUT_TYPE, STATE, OP>(state, aggr_input_data, input, mask, 0);
81663
81674
  }
81664
81675
 
81665
81676
  template <class STATE, class OP>
81666
- static void Combine(const STATE &source, STATE *target, FunctionData *bind_data) {
81677
+ static void Combine(const STATE &source, STATE *target, AggregateInputData &) {
81667
81678
  if (!target->is_set) {
81668
81679
  *target = source;
81669
81680
  }
81670
81681
  }
81671
81682
 
81672
81683
  template <class T, class STATE>
81673
- static void Finalize(Vector &result, FunctionData *, STATE *state, T *target, ValidityMask &mask, idx_t idx) {
81684
+ static void Finalize(Vector &result, AggregateInputData &, STATE *state, T *target, ValidityMask &mask, idx_t idx) {
81674
81685
  if (!state->is_set || state->is_null) {
81675
81686
  mask.SetInvalid(idx);
81676
81687
  } else {
@@ -81701,27 +81712,27 @@ struct FirstFunctionString : public FirstFunctionBase {
81701
81712
  }
81702
81713
 
81703
81714
  template <class INPUT_TYPE, class STATE, class OP>
81704
- static void Operation(STATE *state, FunctionData *bind_data, INPUT_TYPE *input, ValidityMask &mask, idx_t idx) {
81715
+ static void Operation(STATE *state, AggregateInputData &, INPUT_TYPE *input, ValidityMask &mask, idx_t idx) {
81705
81716
  if (LAST || !state->is_set) {
81706
81717
  SetValue(state, input[idx], !mask.RowIsValid(idx));
81707
81718
  }
81708
81719
  }
81709
81720
 
81710
81721
  template <class INPUT_TYPE, class STATE, class OP>
81711
- static void ConstantOperation(STATE *state, FunctionData *bind_data, INPUT_TYPE *input, ValidityMask &mask,
81712
- idx_t count) {
81713
- Operation<INPUT_TYPE, STATE, OP>(state, bind_data, input, mask, 0);
81722
+ static void ConstantOperation(STATE *state, AggregateInputData &aggr_input_data, INPUT_TYPE *input,
81723
+ ValidityMask &mask, idx_t count) {
81724
+ Operation<INPUT_TYPE, STATE, OP>(state, aggr_input_data, input, mask, 0);
81714
81725
  }
81715
81726
 
81716
81727
  template <class STATE, class OP>
81717
- static void Combine(const STATE &source, STATE *target, FunctionData *bind_data) {
81728
+ static void Combine(const STATE &source, STATE *target, AggregateInputData &) {
81718
81729
  if (source.is_set && (LAST || !target->is_set)) {
81719
81730
  SetValue(target, source.value, source.is_null);
81720
81731
  }
81721
81732
  }
81722
81733
 
81723
81734
  template <class T, class STATE>
81724
- static void Finalize(Vector &result, FunctionData *, STATE *state, T *target, ValidityMask &mask, idx_t idx) {
81735
+ static void Finalize(Vector &result, AggregateInputData &, STATE *state, T *target, ValidityMask &mask, idx_t idx) {
81725
81736
  if (!state->is_set || state->is_null) {
81726
81737
  mask.SetInvalid(idx);
81727
81738
  } else {
@@ -81769,7 +81780,7 @@ struct FirstVectorFunction {
81769
81780
  VectorOperations::Copy(input, *state->value, sel, 1, 0, 0);
81770
81781
  }
81771
81782
 
81772
- static void Update(Vector inputs[], FunctionData *, idx_t input_count, Vector &state_vector, idx_t count) {
81783
+ static void Update(Vector inputs[], AggregateInputData &, idx_t input_count, Vector &state_vector, idx_t count) {
81773
81784
  auto &input = inputs[0];
81774
81785
  VectorData sdata;
81775
81786
  state_vector.Orrify(count, sdata);
@@ -81784,14 +81795,14 @@ struct FirstVectorFunction {
81784
81795
  }
81785
81796
 
81786
81797
  template <class STATE, class OP>
81787
- static void Combine(const STATE &source, STATE *target, FunctionData *bind_data) {
81798
+ static void Combine(const STATE &source, STATE *target, AggregateInputData &) {
81788
81799
  if (source.value && (LAST || !target->value)) {
81789
81800
  SetValue(target, *source.value, 0);
81790
81801
  }
81791
81802
  }
81792
81803
 
81793
81804
  template <class T, class STATE>
81794
- static void Finalize(Vector &result, FunctionData *, STATE *state, T *target, ValidityMask &mask, idx_t idx) {
81805
+ static void Finalize(Vector &result, AggregateInputData &, STATE *state, T *target, ValidityMask &mask, idx_t idx) {
81795
81806
  if (!state->value) {
81796
81807
  // we need to use FlatVector::SetNull here
81797
81808
  // since for STRUCT columns only setting the validity mask of the struct is incorrect
@@ -81957,15 +81968,15 @@ struct KurtosisOperation {
81957
81968
  }
81958
81969
 
81959
81970
  template <class INPUT_TYPE, class STATE, class OP>
81960
- static void ConstantOperation(STATE *state, FunctionData *bind_data, INPUT_TYPE *input, ValidityMask &mask,
81961
- idx_t count) {
81971
+ static void ConstantOperation(STATE *state, AggregateInputData &aggr_input_data, INPUT_TYPE *input,
81972
+ ValidityMask &mask, idx_t count) {
81962
81973
  for (idx_t i = 0; i < count; i++) {
81963
- Operation<INPUT_TYPE, STATE, OP>(state, bind_data, input, mask, 0);
81974
+ Operation<INPUT_TYPE, STATE, OP>(state, aggr_input_data, input, mask, 0);
81964
81975
  }
81965
81976
  }
81966
81977
 
81967
81978
  template <class INPUT_TYPE, class STATE, class OP>
81968
- static void Operation(STATE *state, FunctionData *bind_data, INPUT_TYPE *data, ValidityMask &mask, idx_t idx) {
81979
+ static void Operation(STATE *state, AggregateInputData &, INPUT_TYPE *data, ValidityMask &mask, idx_t idx) {
81969
81980
  state->n++;
81970
81981
  state->sum += data[idx];
81971
81982
  state->sum_sqr += pow(data[idx], 2);
@@ -81974,7 +81985,7 @@ struct KurtosisOperation {
81974
81985
  }
81975
81986
 
81976
81987
  template <class STATE, class OP>
81977
- static void Combine(const STATE &source, STATE *target, FunctionData *bind_data) {
81988
+ static void Combine(const STATE &source, STATE *target, AggregateInputData &) {
81978
81989
  if (source.n == 0) {
81979
81990
  return;
81980
81991
  }
@@ -81986,7 +81997,7 @@ struct KurtosisOperation {
81986
81997
  }
81987
81998
 
81988
81999
  template <class TARGET_TYPE, class STATE>
81989
- static void Finalize(Vector &result, FunctionData *bind_data, STATE *state, TARGET_TYPE *target, ValidityMask &mask,
82000
+ static void Finalize(Vector &result, AggregateInputData &, STATE *state, TARGET_TYPE *target, ValidityMask &mask,
81990
82001
  idx_t idx) {
81991
82002
  auto n = (double)state->n;
81992
82003
  if (n <= 3) {
@@ -82094,7 +82105,7 @@ struct MinMaxBase {
82094
82105
  }
82095
82106
 
82096
82107
  template <class INPUT_TYPE, class STATE, class OP>
82097
- static void ConstantOperation(STATE *state, FunctionData *bind_data, INPUT_TYPE *input, ValidityMask &mask,
82108
+ static void ConstantOperation(STATE *state, AggregateInputData &, INPUT_TYPE *input, ValidityMask &mask,
82098
82109
  idx_t count) {
82099
82110
  D_ASSERT(mask.RowIsValid(0));
82100
82111
  if (!state->isset) {
@@ -82106,7 +82117,7 @@ struct MinMaxBase {
82106
82117
  }
82107
82118
 
82108
82119
  template <class INPUT_TYPE, class STATE, class OP>
82109
- static void Operation(STATE *state, FunctionData *bind_data, INPUT_TYPE *input, ValidityMask &mask, idx_t idx) {
82120
+ static void Operation(STATE *state, AggregateInputData &, INPUT_TYPE *input, ValidityMask &mask, idx_t idx) {
82110
82121
  if (!state->isset) {
82111
82122
  OP::template Assign<INPUT_TYPE, STATE>(state, input[idx]);
82112
82123
  state->isset = true;
@@ -82127,7 +82138,7 @@ struct NumericMinMaxBase : public MinMaxBase {
82127
82138
  }
82128
82139
 
82129
82140
  template <class T, class STATE>
82130
- static void Finalize(Vector &result, FunctionData *, STATE *state, T *target, ValidityMask &mask, idx_t idx) {
82141
+ static void Finalize(Vector &result, AggregateInputData &, STATE *state, T *target, ValidityMask &mask, idx_t idx) {
82131
82142
  mask.Set(idx, state->isset);
82132
82143
  target[idx] = state->value;
82133
82144
  }
@@ -82142,7 +82153,7 @@ struct MinOperation : public NumericMinMaxBase {
82142
82153
  }
82143
82154
 
82144
82155
  template <class STATE, class OP>
82145
- static void Combine(const STATE &source, STATE *target, FunctionData *bind_data) {
82156
+ static void Combine(const STATE &source, STATE *target, AggregateInputData &) {
82146
82157
  if (!source.isset) {
82147
82158
  // source is NULL, nothing to do
82148
82159
  return;
@@ -82165,7 +82176,7 @@ struct MaxOperation : public NumericMinMaxBase {
82165
82176
  }
82166
82177
 
82167
82178
  template <class STATE, class OP>
82168
- static void Combine(const STATE &source, STATE *target, FunctionData *bind_data) {
82179
+ static void Combine(const STATE &source, STATE *target, AggregateInputData &) {
82169
82180
  if (!source.isset) {
82170
82181
  // source is NULL, nothing to do
82171
82182
  return;
@@ -82203,7 +82214,7 @@ struct StringMinMaxBase : public MinMaxBase {
82203
82214
  }
82204
82215
 
82205
82216
  template <class T, class STATE>
82206
- static void Finalize(Vector &result, FunctionData *, STATE *state, T *target, ValidityMask &mask, idx_t idx) {
82217
+ static void Finalize(Vector &result, AggregateInputData &, STATE *state, T *target, ValidityMask &mask, idx_t idx) {
82207
82218
  if (!state->isset) {
82208
82219
  mask.SetInvalid(idx);
82209
82220
  } else {
@@ -82212,7 +82223,7 @@ struct StringMinMaxBase : public MinMaxBase {
82212
82223
  }
82213
82224
 
82214
82225
  template <class STATE, class OP>
82215
- static void Combine(const STATE &source, STATE *target, FunctionData *bind_data) {
82226
+ static void Combine(const STATE &source, STATE *target, AggregateInputData &) {
82216
82227
  if (!source.isset) {
82217
82228
  // source is NULL, nothing to do
82218
82229
  return;
@@ -82448,7 +82459,7 @@ struct VectorMinMaxBase {
82448
82459
  }
82449
82460
 
82450
82461
  template <class STATE, class OP>
82451
- static void Update(Vector inputs[], FunctionData *, idx_t input_count, Vector &state_vector, idx_t count) {
82462
+ static void Update(Vector inputs[], AggregateInputData &, idx_t input_count, Vector &state_vector, idx_t count) {
82452
82463
  auto &input = inputs[0];
82453
82464
  VectorData idata;
82454
82465
  input.Orrify(count, idata);
@@ -82473,7 +82484,7 @@ struct VectorMinMaxBase {
82473
82484
  }
82474
82485
 
82475
82486
  template <class STATE, class OP>
82476
- static void Combine(const STATE &source, STATE *target, FunctionData *bind_data) {
82487
+ static void Combine(const STATE &source, STATE *target, AggregateInputData &) {
82477
82488
  if (!source.value) {
82478
82489
  return;
82479
82490
  } else if (!target->value) {
@@ -82484,7 +82495,7 @@ struct VectorMinMaxBase {
82484
82495
  }
82485
82496
 
82486
82497
  template <class T, class STATE>
82487
- static void Finalize(Vector &result, FunctionData *, STATE *state, T *target, ValidityMask &mask, idx_t idx) {
82498
+ static void Finalize(Vector &result, AggregateInputData &, STATE *state, T *target, ValidityMask &mask, idx_t idx) {
82488
82499
  if (!state->value) {
82489
82500
  // we need to use SetNull here
82490
82501
  // since for STRUCT columns only setting the validity mask of the struct is incorrect
@@ -82618,13 +82629,13 @@ struct ProductFunction {
82618
82629
  }
82619
82630
 
82620
82631
  template <class STATE, class OP>
82621
- static void Combine(const STATE &source, STATE *target, FunctionData *bind_data) {
82632
+ static void Combine(const STATE &source, STATE *target, AggregateInputData &) {
82622
82633
  target->val *= source.val;
82623
82634
  target->empty = target->empty && source.empty;
82624
82635
  }
82625
82636
 
82626
82637
  template <class T, class STATE>
82627
- static void Finalize(Vector &result, FunctionData *, STATE *state, T *target, ValidityMask &mask, idx_t idx) {
82638
+ static void Finalize(Vector &result, AggregateInputData &, STATE *state, T *target, ValidityMask &mask, idx_t idx) {
82628
82639
  if (state->empty) {
82629
82640
  mask.SetInvalid(idx);
82630
82641
  return;
@@ -82632,7 +82643,7 @@ struct ProductFunction {
82632
82643
  target[idx] = state->val;
82633
82644
  }
82634
82645
  template <class INPUT_TYPE, class STATE, class OP>
82635
- static void Operation(STATE *state, FunctionData *bind_data, INPUT_TYPE *input, ValidityMask &mask, idx_t idx) {
82646
+ static void Operation(STATE *state, AggregateInputData &, INPUT_TYPE *input, ValidityMask &mask, idx_t idx) {
82636
82647
  if (state->empty) {
82637
82648
  state->empty = false;
82638
82649
  }
@@ -82640,10 +82651,10 @@ struct ProductFunction {
82640
82651
  }
82641
82652
 
82642
82653
  template <class INPUT_TYPE, class STATE, class OP>
82643
- static void ConstantOperation(STATE *state, FunctionData *bind_data, INPUT_TYPE *input, ValidityMask &mask,
82644
- idx_t count) {
82654
+ static void ConstantOperation(STATE *state, AggregateInputData &aggr_input_data, INPUT_TYPE *input,
82655
+ ValidityMask &mask, idx_t count) {
82645
82656
  for (idx_t i = 0; i < count; i++) {
82646
- Operation<INPUT_TYPE, STATE, OP>(state, bind_data, input, mask, 0);
82657
+ Operation<INPUT_TYPE, STATE, OP>(state, aggr_input_data, input, mask, 0);
82647
82658
  }
82648
82659
  }
82649
82660
 
@@ -82689,15 +82700,15 @@ struct SkewnessOperation {
82689
82700
  }
82690
82701
 
82691
82702
  template <class INPUT_TYPE, class STATE, class OP>
82692
- static void ConstantOperation(STATE *state, FunctionData *bind_data, INPUT_TYPE *input, ValidityMask &mask,
82693
- idx_t count) {
82703
+ static void ConstantOperation(STATE *state, AggregateInputData &aggr_input_data, INPUT_TYPE *input,
82704
+ ValidityMask &mask, idx_t count) {
82694
82705
  for (idx_t i = 0; i < count; i++) {
82695
- Operation<INPUT_TYPE, STATE, OP>(state, bind_data, input, mask, 0);
82706
+ Operation<INPUT_TYPE, STATE, OP>(state, aggr_input_data, input, mask, 0);
82696
82707
  }
82697
82708
  }
82698
82709
 
82699
82710
  template <class INPUT_TYPE, class STATE, class OP>
82700
- static void Operation(STATE *state, FunctionData *bind_data, INPUT_TYPE *data, ValidityMask &mask, idx_t idx) {
82711
+ static void Operation(STATE *state, AggregateInputData &, INPUT_TYPE *data, ValidityMask &mask, idx_t idx) {
82701
82712
  state->n++;
82702
82713
  state->sum += data[idx];
82703
82714
  state->sum_sqr += pow(data[idx], 2);
@@ -82705,7 +82716,7 @@ struct SkewnessOperation {
82705
82716
  }
82706
82717
 
82707
82718
  template <class STATE, class OP>
82708
- static void Combine(const STATE &source, STATE *target, FunctionData *bind_data) {
82719
+ static void Combine(const STATE &source, STATE *target, AggregateInputData &) {
82709
82720
  if (source.n == 0) {
82710
82721
  return;
82711
82722
  }
@@ -82717,7 +82728,7 @@ struct SkewnessOperation {
82717
82728
  }
82718
82729
 
82719
82730
  template <class TARGET_TYPE, class STATE>
82720
- static void Finalize(Vector &result, FunctionData *bind_data, STATE *state, TARGET_TYPE *target, ValidityMask &mask,
82731
+ static void Finalize(Vector &result, AggregateInputData &, STATE *state, TARGET_TYPE *target, ValidityMask &mask,
82721
82732
  idx_t idx) {
82722
82733
  if (state->n <= 2) {
82723
82734
  mask.SetInvalid(idx);
@@ -82792,7 +82803,7 @@ struct StringAggFunction {
82792
82803
  }
82793
82804
 
82794
82805
  template <class T, class STATE>
82795
- static void Finalize(Vector &result, FunctionData *, STATE *state, T *target, ValidityMask &mask, idx_t idx) {
82806
+ static void Finalize(Vector &result, AggregateInputData &, STATE *state, T *target, ValidityMask &mask, idx_t idx) {
82796
82807
  if (!state->dataptr) {
82797
82808
  mask.SetInvalid(idx);
82798
82809
  } else {
@@ -82847,26 +82858,26 @@ struct StringAggFunction {
82847
82858
  }
82848
82859
 
82849
82860
  template <class INPUT_TYPE, class STATE, class OP>
82850
- static void Operation(STATE *state, FunctionData *bind_data, INPUT_TYPE *str_data, ValidityMask &str_mask,
82851
- idx_t str_idx) {
82852
- PerformOperation(state, str_data[str_idx], bind_data);
82861
+ static void Operation(STATE *state, AggregateInputData &aggr_input_data, INPUT_TYPE *str_data,
82862
+ ValidityMask &str_mask, idx_t str_idx) {
82863
+ PerformOperation(state, str_data[str_idx], aggr_input_data.bind_data);
82853
82864
  }
82854
82865
 
82855
82866
  template <class INPUT_TYPE, class STATE, class OP>
82856
- static void ConstantOperation(STATE *state, FunctionData *bind_data, INPUT_TYPE *input, ValidityMask &mask,
82857
- idx_t count) {
82867
+ static void ConstantOperation(STATE *state, AggregateInputData &aggr_input_data, INPUT_TYPE *input,
82868
+ ValidityMask &mask, idx_t count) {
82858
82869
  for (idx_t i = 0; i < count; i++) {
82859
- Operation<INPUT_TYPE, STATE, OP>(state, bind_data, input, mask, 0);
82870
+ Operation<INPUT_TYPE, STATE, OP>(state, aggr_input_data, input, mask, 0);
82860
82871
  }
82861
82872
  }
82862
82873
 
82863
82874
  template <class STATE, class OP>
82864
- static void Combine(const STATE &source, STATE *target, FunctionData *bind_data) {
82875
+ static void Combine(const STATE &source, STATE *target, AggregateInputData &aggr_input_data) {
82865
82876
  if (!source.dataptr) {
82866
82877
  // source is not set: skip combining
82867
82878
  return;
82868
82879
  }
82869
- PerformOperation(target, string_t(source.dataptr, source.size), bind_data);
82880
+ PerformOperation(target, string_t(source.dataptr, source.size), aggr_input_data.bind_data);
82870
82881
  }
82871
82882
  };
82872
82883
 
@@ -82929,7 +82940,7 @@ struct SumSetOperation {
82929
82940
  state->Initialize();
82930
82941
  }
82931
82942
  template <class STATE>
82932
- static void Combine(const STATE &source, STATE *target, FunctionData *bind_data) {
82943
+ static void Combine(const STATE &source, STATE *target, AggregateInputData &) {
82933
82944
  target->Combine(source);
82934
82945
  }
82935
82946
  template <class STATE>
@@ -82940,7 +82951,7 @@ struct SumSetOperation {
82940
82951
 
82941
82952
  struct IntegerSumOperation : public BaseSumOperation<SumSetOperation, RegularAdd> {
82942
82953
  template <class T, class STATE>
82943
- static void Finalize(Vector &result, FunctionData *, STATE *state, T *target, ValidityMask &mask, idx_t idx) {
82954
+ static void Finalize(Vector &result, AggregateInputData &, STATE *state, T *target, ValidityMask &mask, idx_t idx) {
82944
82955
  if (!state->isset) {
82945
82956
  mask.SetInvalid(idx);
82946
82957
  } else {
@@ -82951,7 +82962,7 @@ struct IntegerSumOperation : public BaseSumOperation<SumSetOperation, RegularAdd
82951
82962
 
82952
82963
  struct SumToHugeintOperation : public BaseSumOperation<SumSetOperation, HugeintAdd> {
82953
82964
  template <class T, class STATE>
82954
- static void Finalize(Vector &result, FunctionData *, STATE *state, T *target, ValidityMask &mask, idx_t idx) {
82965
+ static void Finalize(Vector &result, AggregateInputData &, STATE *state, T *target, ValidityMask &mask, idx_t idx) {
82955
82966
  if (!state->isset) {
82956
82967
  mask.SetInvalid(idx);
82957
82968
  } else {
@@ -82963,7 +82974,7 @@ struct SumToHugeintOperation : public BaseSumOperation<SumSetOperation, HugeintA
82963
82974
  template <class ADD_OPERATOR>
82964
82975
  struct DoubleSumOperation : public BaseSumOperation<SumSetOperation, ADD_OPERATOR> {
82965
82976
  template <class T, class STATE>
82966
- static void Finalize(Vector &result, FunctionData *, STATE *state, T *target, ValidityMask &mask, idx_t idx) {
82977
+ static void Finalize(Vector &result, AggregateInputData &, STATE *state, T *target, ValidityMask &mask, idx_t idx) {
82967
82978
  if (!state->isset) {
82968
82979
  mask.SetInvalid(idx);
82969
82980
  } else {
@@ -82980,7 +82991,7 @@ using KahanSumOperation = DoubleSumOperation<KahanAdd>;
82980
82991
 
82981
82992
  struct HugeintSumOperation : public BaseSumOperation<SumSetOperation, RegularAdd> {
82982
82993
  template <class T, class STATE>
82983
- static void Finalize(Vector &result, FunctionData *, STATE *state, T *target, ValidityMask &mask, idx_t idx) {
82994
+ static void Finalize(Vector &result, AggregateInputData &, STATE *state, T *target, ValidityMask &mask, idx_t idx) {
82984
82995
  if (!state->isset) {
82985
82996
  mask.SetInvalid(idx);
82986
82997
  } else {
@@ -83890,15 +83901,15 @@ struct ApproxQuantileOperation {
83890
83901
  }
83891
83902
 
83892
83903
  template <class INPUT_TYPE, class STATE, class OP>
83893
- static void ConstantOperation(STATE *state, FunctionData *bind_data, INPUT_TYPE *input, ValidityMask &mask,
83894
- idx_t count) {
83904
+ static void ConstantOperation(STATE *state, AggregateInputData &aggr_input_data, INPUT_TYPE *input,
83905
+ ValidityMask &mask, idx_t count) {
83895
83906
  for (idx_t i = 0; i < count; i++) {
83896
- Operation<INPUT_TYPE, STATE, OP>(state, bind_data, input, mask, 0);
83907
+ Operation<INPUT_TYPE, STATE, OP>(state, aggr_input_data, input, mask, 0);
83897
83908
  }
83898
83909
  }
83899
83910
 
83900
83911
  template <class INPUT_TYPE, class STATE, class OP>
83901
- static void Operation(STATE *state, FunctionData *bind_data, INPUT_TYPE *data, ValidityMask &mask, idx_t idx) {
83912
+ static void Operation(STATE *state, AggregateInputData &, INPUT_TYPE *data, ValidityMask &mask, idx_t idx) {
83902
83913
  if (!state->h) {
83903
83914
  state->h = new duckdb_tdigest::TDigest(100);
83904
83915
  }
@@ -83908,7 +83919,7 @@ struct ApproxQuantileOperation {
83908
83919
  }
83909
83920
 
83910
83921
  template <class STATE, class OP>
83911
- static void Combine(const STATE &source, STATE *target, FunctionData *bind_data) {
83922
+ static void Combine(const STATE &source, STATE *target, AggregateInputData &) {
83912
83923
  if (source.pos == 0) {
83913
83924
  return;
83914
83925
  }
@@ -83935,7 +83946,7 @@ struct ApproxQuantileOperation {
83935
83946
  struct ApproxQuantileScalarOperation : public ApproxQuantileOperation {
83936
83947
 
83937
83948
  template <class TARGET_TYPE, class STATE>
83938
- static void Finalize(Vector &result, FunctionData *bind_data_p, STATE *state, TARGET_TYPE *target,
83949
+ static void Finalize(Vector &result, AggregateInputData &aggr_input_data, STATE *state, TARGET_TYPE *target,
83939
83950
  ValidityMask &mask, idx_t idx) {
83940
83951
 
83941
83952
  if (state->pos == 0) {
@@ -83943,9 +83954,9 @@ struct ApproxQuantileScalarOperation : public ApproxQuantileOperation {
83943
83954
  return;
83944
83955
  }
83945
83956
  D_ASSERT(state->h);
83946
- D_ASSERT(bind_data_p);
83957
+ D_ASSERT(aggr_input_data.bind_data);
83947
83958
  state->h->compress();
83948
- auto bind_data = (ApproximateQuantileBindData *)bind_data_p;
83959
+ auto bind_data = (ApproximateQuantileBindData *)aggr_input_data.bind_data;
83949
83960
  D_ASSERT(bind_data->quantiles.size() == 1);
83950
83961
  target[idx] = Cast::template Operation<SAVE_TYPE, TARGET_TYPE>(state->h->quantile(bind_data->quantiles[0]));
83951
83962
  }
@@ -84028,15 +84039,15 @@ template <class CHILD_TYPE>
84028
84039
  struct ApproxQuantileListOperation : public ApproxQuantileOperation {
84029
84040
 
84030
84041
  template <class RESULT_TYPE, class STATE>
84031
- static void Finalize(Vector &result_list, FunctionData *bind_data_p, STATE *state, RESULT_TYPE *target,
84042
+ static void Finalize(Vector &result_list, AggregateInputData &aggr_input_data, STATE *state, RESULT_TYPE *target,
84032
84043
  ValidityMask &mask, idx_t idx) {
84033
84044
  if (state->pos == 0) {
84034
84045
  mask.SetInvalid(idx);
84035
84046
  return;
84036
84047
  }
84037
84048
 
84038
- D_ASSERT(bind_data_p);
84039
- auto bind_data = (ApproximateQuantileBindData *)bind_data_p;
84049
+ D_ASSERT(aggr_input_data.bind_data);
84050
+ auto bind_data = (ApproximateQuantileBindData *)aggr_input_data.bind_data;
84040
84051
 
84041
84052
  auto &result = ListVector::GetEntry(result_list);
84042
84053
  auto ridx = ListVector::GetListSize(result_list);
@@ -84058,12 +84069,12 @@ struct ApproxQuantileListOperation : public ApproxQuantileOperation {
84058
84069
  }
84059
84070
 
84060
84071
  template <class STATE_TYPE, class RESULT_TYPE>
84061
- static void FinalizeList(Vector &states, FunctionData *bind_data_p, Vector &result, idx_t count, // NOLINT
84072
+ static void FinalizeList(Vector &states, AggregateInputData &aggr_input_data, Vector &result, idx_t count, // NOLINT
84062
84073
  idx_t offset) {
84063
84074
  D_ASSERT(result.GetType().id() == LogicalTypeId::LIST);
84064
84075
 
84065
- D_ASSERT(bind_data_p);
84066
- auto bind_data = (ApproximateQuantileBindData *)bind_data_p;
84076
+ D_ASSERT(aggr_input_data.bind_data);
84077
+ auto bind_data = (ApproximateQuantileBindData *)aggr_input_data.bind_data;
84067
84078
 
84068
84079
  if (states.GetVectorType() == VectorType::CONSTANT_VECTOR) {
84069
84080
  result.SetVectorType(VectorType::CONSTANT_VECTOR);
@@ -84072,7 +84083,7 @@ struct ApproxQuantileListOperation : public ApproxQuantileOperation {
84072
84083
  auto sdata = ConstantVector::GetData<STATE_TYPE *>(states);
84073
84084
  auto rdata = ConstantVector::GetData<RESULT_TYPE>(result);
84074
84085
  auto &mask = ConstantVector::Validity(result);
84075
- Finalize<RESULT_TYPE, STATE_TYPE>(result, bind_data, sdata[0], rdata, mask, 0);
84086
+ Finalize<RESULT_TYPE, STATE_TYPE>(result, aggr_input_data, sdata[0], rdata, mask, 0);
84076
84087
  } else {
84077
84088
  D_ASSERT(states.GetVectorType() == VectorType::FLAT_VECTOR);
84078
84089
  result.SetVectorType(VectorType::FLAT_VECTOR);
@@ -84082,7 +84093,7 @@ struct ApproxQuantileListOperation : public ApproxQuantileOperation {
84082
84093
  auto rdata = FlatVector::GetData<RESULT_TYPE>(result);
84083
84094
  auto &mask = FlatVector::Validity(result);
84084
84095
  for (idx_t i = 0; i < count; i++) {
84085
- Finalize<RESULT_TYPE, STATE_TYPE>(result, bind_data, sdata[i], rdata, mask, i + offset);
84096
+ Finalize<RESULT_TYPE, STATE_TYPE>(result, aggr_input_data, sdata[i], rdata, mask, i + offset);
84086
84097
  }
84087
84098
  }
84088
84099
 
@@ -84323,7 +84334,7 @@ struct ModeFunction {
84323
84334
  }
84324
84335
 
84325
84336
  template <class INPUT_TYPE, class STATE, class OP>
84326
- static void Operation(STATE *state, FunctionData *bind_data, INPUT_TYPE *input, ValidityMask &mask, idx_t idx) {
84337
+ static void Operation(STATE *state, AggregateInputData &, INPUT_TYPE *input, ValidityMask &mask, idx_t idx) {
84327
84338
  if (!state->frequency_map) {
84328
84339
  state->frequency_map = new unordered_map<KEY_TYPE, size_t>();
84329
84340
  }
@@ -84332,7 +84343,7 @@ struct ModeFunction {
84332
84343
  }
84333
84344
 
84334
84345
  template <class STATE, class OP>
84335
- static void Combine(const STATE &source, STATE *target, FunctionData *bind_data) {
84346
+ static void Combine(const STATE &source, STATE *target, AggregateInputData &) {
84336
84347
  if (!source.frequency_map) {
84337
84348
  return;
84338
84349
  }
@@ -84347,7 +84358,7 @@ struct ModeFunction {
84347
84358
  }
84348
84359
 
84349
84360
  template <class INPUT_TYPE, class STATE>
84350
- static void Finalize(Vector &result, FunctionData *, STATE *state, INPUT_TYPE *target, ValidityMask &mask,
84361
+ static void Finalize(Vector &result, AggregateInputData &, STATE *state, INPUT_TYPE *target, ValidityMask &mask,
84351
84362
  idx_t idx) {
84352
84363
  if (!state->frequency_map) {
84353
84364
  mask.SetInvalid(idx);
@@ -84361,7 +84372,7 @@ struct ModeFunction {
84361
84372
  }
84362
84373
  }
84363
84374
  template <class INPUT_TYPE, class STATE, class OP>
84364
- static void ConstantOperation(STATE *state, FunctionData *bind_data, INPUT_TYPE *input, ValidityMask &mask,
84375
+ static void ConstantOperation(STATE *state, AggregateInputData &, INPUT_TYPE *input, ValidityMask &mask,
84365
84376
  idx_t count) {
84366
84377
  if (!state->frequency_map) {
84367
84378
  state->frequency_map = new unordered_map<KEY_TYPE, size_t>();
@@ -84372,7 +84383,7 @@ struct ModeFunction {
84372
84383
 
84373
84384
  template <class STATE, class INPUT_TYPE, class RESULT_TYPE>
84374
84385
  static void Window(const INPUT_TYPE *data, const ValidityMask &fmask, const ValidityMask &dmask,
84375
- FunctionData *bind_data_p, STATE *state, const FrameBounds &frame, const FrameBounds &prev,
84386
+ AggregateInputData &, STATE *state, const FrameBounds &frame, const FrameBounds &prev,
84376
84387
  Vector &result, idx_t rid, idx_t bias) {
84377
84388
  auto rdata = FlatVector::GetData<RESULT_TYPE>(result);
84378
84389
  auto &rmask = FlatVector::Validity(result);
@@ -84981,20 +84992,20 @@ struct QuantileOperation {
84981
84992
  }
84982
84993
 
84983
84994
  template <class INPUT_TYPE, class STATE, class OP>
84984
- static void ConstantOperation(STATE *state, FunctionData *bind_data, INPUT_TYPE *input, ValidityMask &mask,
84985
- idx_t count) {
84995
+ static void ConstantOperation(STATE *state, AggregateInputData &aggr_input_data, INPUT_TYPE *input,
84996
+ ValidityMask &mask, idx_t count) {
84986
84997
  for (idx_t i = 0; i < count; i++) {
84987
- Operation<INPUT_TYPE, STATE, OP>(state, bind_data, input, mask, 0);
84998
+ Operation<INPUT_TYPE, STATE, OP>(state, aggr_input_data, input, mask, 0);
84988
84999
  }
84989
85000
  }
84990
85001
 
84991
85002
  template <class INPUT_TYPE, class STATE, class OP>
84992
- static void Operation(STATE *state, FunctionData *bind_data_p, INPUT_TYPE *data, ValidityMask &mask, idx_t idx) {
85003
+ static void Operation(STATE *state, AggregateInputData &, INPUT_TYPE *data, ValidityMask &mask, idx_t idx) {
84993
85004
  state->v.emplace_back(data[idx]);
84994
85005
  }
84995
85006
 
84996
85007
  template <class STATE, class OP>
84997
- static void Combine(const STATE &source, STATE *target, FunctionData *bind_data) {
85008
+ static void Combine(const STATE &source, STATE *target, AggregateInputData &) {
84998
85009
  if (source.v.empty()) {
84999
85010
  return;
85000
85011
  }
@@ -85012,12 +85023,13 @@ struct QuantileOperation {
85012
85023
  };
85013
85024
 
85014
85025
  template <class STATE_TYPE, class RESULT_TYPE, class OP>
85015
- static void ExecuteListFinalize(Vector &states, FunctionData *bind_data_p, Vector &result, idx_t count, // NOLINT
85026
+ static void ExecuteListFinalize(Vector &states, AggregateInputData &aggr_input_data, Vector &result,
85027
+ idx_t count, // NOLINT
85016
85028
  idx_t offset) {
85017
85029
  D_ASSERT(result.GetType().id() == LogicalTypeId::LIST);
85018
85030
 
85019
- D_ASSERT(bind_data_p);
85020
- auto bind_data = (QuantileBindData *)bind_data_p;
85031
+ D_ASSERT(aggr_input_data.bind_data);
85032
+ auto bind_data = (QuantileBindData *)aggr_input_data.bind_data;
85021
85033
 
85022
85034
  if (states.GetVectorType() == VectorType::CONSTANT_VECTOR) {
85023
85035
  result.SetVectorType(VectorType::CONSTANT_VECTOR);
@@ -85026,7 +85038,7 @@ static void ExecuteListFinalize(Vector &states, FunctionData *bind_data_p, Vecto
85026
85038
  auto sdata = ConstantVector::GetData<STATE_TYPE *>(states);
85027
85039
  auto rdata = ConstantVector::GetData<RESULT_TYPE>(result);
85028
85040
  auto &mask = ConstantVector::Validity(result);
85029
- OP::template Finalize<RESULT_TYPE, STATE_TYPE>(result, bind_data, sdata[0], rdata, mask, 0);
85041
+ OP::template Finalize<RESULT_TYPE, STATE_TYPE>(result, aggr_input_data, sdata[0], rdata, mask, 0);
85030
85042
  } else {
85031
85043
  D_ASSERT(states.GetVectorType() == VectorType::FLAT_VECTOR);
85032
85044
  result.SetVectorType(VectorType::FLAT_VECTOR);
@@ -85036,7 +85048,7 @@ static void ExecuteListFinalize(Vector &states, FunctionData *bind_data_p, Vecto
85036
85048
  auto rdata = FlatVector::GetData<RESULT_TYPE>(result);
85037
85049
  auto &mask = FlatVector::Validity(result);
85038
85050
  for (idx_t i = 0; i < count; i++) {
85039
- OP::template Finalize<RESULT_TYPE, STATE_TYPE>(result, bind_data, sdata[i], rdata, mask, i + offset);
85051
+ OP::template Finalize<RESULT_TYPE, STATE_TYPE>(result, aggr_input_data, sdata[i], rdata, mask, i + offset);
85040
85052
  }
85041
85053
  }
85042
85054
 
@@ -85057,14 +85069,14 @@ template <bool DISCRETE>
85057
85069
  struct QuantileScalarOperation : public QuantileOperation {
85058
85070
 
85059
85071
  template <class RESULT_TYPE, class STATE>
85060
- static void Finalize(Vector &result, FunctionData *bind_data_p, STATE *state, RESULT_TYPE *target,
85072
+ static void Finalize(Vector &result, AggregateInputData &aggr_input_data, STATE *state, RESULT_TYPE *target,
85061
85073
  ValidityMask &mask, idx_t idx) {
85062
85074
  if (state->v.empty()) {
85063
85075
  mask.SetInvalid(idx);
85064
85076
  return;
85065
85077
  }
85066
- D_ASSERT(bind_data_p);
85067
- auto bind_data = (QuantileBindData *)bind_data_p;
85078
+ D_ASSERT(aggr_input_data.bind_data);
85079
+ auto bind_data = (QuantileBindData *)aggr_input_data.bind_data;
85068
85080
  D_ASSERT(bind_data->quantiles.size() == 1);
85069
85081
  Interpolator<DISCRETE> interp(bind_data->quantiles[0], state->v.size());
85070
85082
  target[idx] = interp.template Operation<typename STATE::SaveType, RESULT_TYPE>(state->v.data(), result);
@@ -85072,8 +85084,8 @@ struct QuantileScalarOperation : public QuantileOperation {
85072
85084
 
85073
85085
  template <class STATE, class INPUT_TYPE, class RESULT_TYPE>
85074
85086
  static void Window(const INPUT_TYPE *data, const ValidityMask &fmask, const ValidityMask &dmask,
85075
- FunctionData *bind_data_p, STATE *state, const FrameBounds &frame, const FrameBounds &prev,
85076
- Vector &result, idx_t ridx, idx_t bias) {
85087
+ AggregateInputData &aggr_input_data, STATE *state, const FrameBounds &frame,
85088
+ const FrameBounds &prev, Vector &result, idx_t ridx, idx_t bias) {
85077
85089
  auto rdata = FlatVector::GetData<RESULT_TYPE>(result);
85078
85090
  auto &rmask = FlatVector::Validity(result);
85079
85091
 
@@ -85086,8 +85098,8 @@ struct QuantileScalarOperation : public QuantileOperation {
85086
85098
  auto index = state->w.data();
85087
85099
  D_ASSERT(index);
85088
85100
 
85089
- D_ASSERT(bind_data_p);
85090
- auto bind_data = (QuantileBindData *)bind_data_p;
85101
+ D_ASSERT(aggr_input_data.bind_data);
85102
+ auto bind_data = (QuantileBindData *)aggr_input_data.bind_data;
85091
85103
 
85092
85104
  // Find the two positions needed
85093
85105
  const auto q = bind_data->quantiles[0];
@@ -85189,15 +85201,15 @@ template <class CHILD_TYPE, bool DISCRETE>
85189
85201
  struct QuantileListOperation : public QuantileOperation {
85190
85202
 
85191
85203
  template <class RESULT_TYPE, class STATE>
85192
- static void Finalize(Vector &result_list, FunctionData *bind_data_p, STATE *state, RESULT_TYPE *target,
85204
+ static void Finalize(Vector &result_list, AggregateInputData &aggr_input_data, STATE *state, RESULT_TYPE *target,
85193
85205
  ValidityMask &mask, idx_t idx) {
85194
85206
  if (state->v.empty()) {
85195
85207
  mask.SetInvalid(idx);
85196
85208
  return;
85197
85209
  }
85198
85210
 
85199
- D_ASSERT(bind_data_p);
85200
- auto bind_data = (QuantileBindData *)bind_data_p;
85211
+ D_ASSERT(aggr_input_data.bind_data);
85212
+ auto bind_data = (QuantileBindData *)aggr_input_data.bind_data;
85201
85213
 
85202
85214
  auto &result = ListVector::GetEntry(result_list);
85203
85215
  auto ridx = ListVector::GetListSize(result_list);
@@ -85224,10 +85236,10 @@ struct QuantileListOperation : public QuantileOperation {
85224
85236
 
85225
85237
  template <class STATE, class INPUT_TYPE, class RESULT_TYPE>
85226
85238
  static void Window(const INPUT_TYPE *data, const ValidityMask &fmask, const ValidityMask &dmask,
85227
- FunctionData *bind_data_p, STATE *state, const FrameBounds &frame, const FrameBounds &prev,
85228
- Vector &list, idx_t lidx, idx_t bias) {
85229
- D_ASSERT(bind_data_p);
85230
- auto bind_data = (QuantileBindData *)bind_data_p;
85239
+ AggregateInputData &aggr_input_data, STATE *state, const FrameBounds &frame,
85240
+ const FrameBounds &prev, Vector &list, idx_t lidx, idx_t bias) {
85241
+ D_ASSERT(aggr_input_data.bind_data);
85242
+ auto bind_data = (QuantileBindData *)aggr_input_data.bind_data;
85231
85243
 
85232
85244
  QuantileIncluded included(fmask, dmask, bias);
85233
85245
 
@@ -85568,8 +85580,8 @@ template <typename MEDIAN_TYPE>
85568
85580
  struct MedianAbsoluteDeviationOperation : public QuantileOperation {
85569
85581
 
85570
85582
  template <class RESULT_TYPE, class STATE>
85571
- static void Finalize(Vector &result, FunctionData *bind_data_p, STATE *state, RESULT_TYPE *target,
85572
- ValidityMask &mask, idx_t idx) {
85583
+ static void Finalize(Vector &result, AggregateInputData &, STATE *state, RESULT_TYPE *target, ValidityMask &mask,
85584
+ idx_t idx) {
85573
85585
  if (state->v.empty()) {
85574
85586
  mask.SetInvalid(idx);
85575
85587
  return;
@@ -85584,7 +85596,7 @@ struct MedianAbsoluteDeviationOperation : public QuantileOperation {
85584
85596
 
85585
85597
  template <class STATE, class INPUT_TYPE, class RESULT_TYPE>
85586
85598
  static void Window(const INPUT_TYPE *data, const ValidityMask &fmask, const ValidityMask &dmask,
85587
- FunctionData *bind_data_p, STATE *state, const FrameBounds &frame, const FrameBounds &prev,
85599
+ AggregateInputData &, STATE *state, const FrameBounds &frame, const FrameBounds &prev,
85588
85600
  Vector &result, idx_t ridx, idx_t bias) {
85589
85601
  auto rdata = FlatVector::GetData<RESULT_TYPE>(result);
85590
85602
  auto &rmask = FlatVector::Validity(result);
@@ -85976,16 +85988,17 @@ struct ReservoirQuantileOperation {
85976
85988
  }
85977
85989
 
85978
85990
  template <class INPUT_TYPE, class STATE, class OP>
85979
- static void ConstantOperation(STATE *state, FunctionData *bind_data, INPUT_TYPE *input, ValidityMask &mask,
85980
- idx_t count) {
85991
+ static void ConstantOperation(STATE *state, AggregateInputData &aggr_input_data, INPUT_TYPE *input,
85992
+ ValidityMask &mask, idx_t count) {
85981
85993
  for (idx_t i = 0; i < count; i++) {
85982
- Operation<INPUT_TYPE, STATE, OP>(state, bind_data, input, mask, 0);
85994
+ Operation<INPUT_TYPE, STATE, OP>(state, aggr_input_data, input, mask, 0);
85983
85995
  }
85984
85996
  }
85985
85997
 
85986
85998
  template <class INPUT_TYPE, class STATE, class OP>
85987
- static void Operation(STATE *state, FunctionData *bind_data_p, INPUT_TYPE *data, ValidityMask &mask, idx_t idx) {
85988
- auto bind_data = (ReservoirQuantileBindData *)bind_data_p;
85999
+ static void Operation(STATE *state, AggregateInputData &aggr_input_data, INPUT_TYPE *data, ValidityMask &mask,
86000
+ idx_t idx) {
86001
+ auto bind_data = (ReservoirQuantileBindData *)aggr_input_data.bind_data;
85989
86002
  D_ASSERT(bind_data);
85990
86003
  if (state->pos == 0) {
85991
86004
  state->Resize(bind_data->sample_size);
@@ -85998,7 +86011,7 @@ struct ReservoirQuantileOperation {
85998
86011
  }
85999
86012
 
86000
86013
  template <class STATE, class OP>
86001
- static void Combine(const STATE &source, STATE *target, FunctionData *bind_data) {
86014
+ static void Combine(const STATE &source, STATE *target, AggregateInputData &) {
86002
86015
  if (source.pos == 0) {
86003
86016
  return;
86004
86017
  }
@@ -86032,15 +86045,15 @@ struct ReservoirQuantileOperation {
86032
86045
 
86033
86046
  struct ReservoirQuantileScalarOperation : public ReservoirQuantileOperation {
86034
86047
  template <class TARGET_TYPE, class STATE>
86035
- static void Finalize(Vector &result, FunctionData *bind_data_p, STATE *state, TARGET_TYPE *target,
86048
+ static void Finalize(Vector &result, AggregateInputData &aggr_input_data, STATE *state, TARGET_TYPE *target,
86036
86049
  ValidityMask &mask, idx_t idx) {
86037
86050
  if (state->pos == 0) {
86038
86051
  mask.SetInvalid(idx);
86039
86052
  return;
86040
86053
  }
86041
86054
  D_ASSERT(state->v);
86042
- D_ASSERT(bind_data_p);
86043
- auto bind_data = (ReservoirQuantileBindData *)bind_data_p;
86055
+ D_ASSERT(aggr_input_data.bind_data);
86056
+ auto bind_data = (ReservoirQuantileBindData *)aggr_input_data.bind_data;
86044
86057
  auto v_t = state->v;
86045
86058
  D_ASSERT(bind_data->quantiles.size() == 1);
86046
86059
  auto offset = (idx_t)((double)(state->pos - 1) * bind_data->quantiles[0]);
@@ -86092,15 +86105,15 @@ template <class CHILD_TYPE>
86092
86105
  struct ReservoirQuantileListOperation : public ReservoirQuantileOperation {
86093
86106
 
86094
86107
  template <class RESULT_TYPE, class STATE>
86095
- static void Finalize(Vector &result_list, FunctionData *bind_data_p, STATE *state, RESULT_TYPE *target,
86108
+ static void Finalize(Vector &result_list, AggregateInputData &aggr_input_data, STATE *state, RESULT_TYPE *target,
86096
86109
  ValidityMask &mask, idx_t idx) {
86097
86110
  if (state->pos == 0) {
86098
86111
  mask.SetInvalid(idx);
86099
86112
  return;
86100
86113
  }
86101
86114
 
86102
- D_ASSERT(bind_data_p);
86103
- auto bind_data = (ReservoirQuantileBindData *)bind_data_p;
86115
+ D_ASSERT(aggr_input_data.bind_data);
86116
+ auto bind_data = (ReservoirQuantileBindData *)aggr_input_data.bind_data;
86104
86117
 
86105
86118
  auto &result = ListVector::GetEntry(result_list);
86106
86119
  auto ridx = ListVector::GetListSize(result_list);
@@ -86124,12 +86137,12 @@ struct ReservoirQuantileListOperation : public ReservoirQuantileOperation {
86124
86137
  }
86125
86138
 
86126
86139
  template <class STATE_TYPE, class RESULT_TYPE>
86127
- static void FinalizeList(Vector &states, FunctionData *bind_data_p, Vector &result, idx_t count, // NOLINT
86140
+ static void FinalizeList(Vector &states, AggregateInputData &aggr_input_data, Vector &result, idx_t count, // NOLINT
86128
86141
  idx_t offset) {
86129
86142
  D_ASSERT(result.GetType().id() == LogicalTypeId::LIST);
86130
86143
 
86131
- D_ASSERT(bind_data_p);
86132
- auto bind_data = (ReservoirQuantileBindData *)bind_data_p;
86144
+ D_ASSERT(aggr_input_data.bind_data);
86145
+ auto bind_data = (ReservoirQuantileBindData *)aggr_input_data.bind_data;
86133
86146
 
86134
86147
  if (states.GetVectorType() == VectorType::CONSTANT_VECTOR) {
86135
86148
  result.SetVectorType(VectorType::CONSTANT_VECTOR);
@@ -86138,7 +86151,7 @@ struct ReservoirQuantileListOperation : public ReservoirQuantileOperation {
86138
86151
  auto sdata = ConstantVector::GetData<STATE_TYPE *>(states);
86139
86152
  auto rdata = ConstantVector::GetData<RESULT_TYPE>(result);
86140
86153
  auto &mask = ConstantVector::Validity(result);
86141
- Finalize<RESULT_TYPE, STATE_TYPE>(result, bind_data, sdata[0], rdata, mask, 0);
86154
+ Finalize<RESULT_TYPE, STATE_TYPE>(result, aggr_input_data, sdata[0], rdata, mask, 0);
86142
86155
  } else {
86143
86156
  D_ASSERT(states.GetVectorType() == VectorType::FLAT_VECTOR);
86144
86157
  result.SetVectorType(VectorType::FLAT_VECTOR);
@@ -86148,7 +86161,7 @@ struct ReservoirQuantileListOperation : public ReservoirQuantileOperation {
86148
86161
  auto rdata = FlatVector::GetData<RESULT_TYPE>(result);
86149
86162
  auto &mask = FlatVector::Validity(result);
86150
86163
  for (idx_t i = 0; i < count; i++) {
86151
- Finalize<RESULT_TYPE, STATE_TYPE>(result, bind_data, sdata[i], rdata, mask, i + offset);
86164
+ Finalize<RESULT_TYPE, STATE_TYPE>(result, aggr_input_data, sdata[i], rdata, mask, i + offset);
86152
86165
  }
86153
86166
  }
86154
86167
 
@@ -86448,7 +86461,7 @@ struct HistogramFunction {
86448
86461
  };
86449
86462
 
86450
86463
  template <class OP, class T, class MAP_TYPE>
86451
- static void HistogramUpdateFunction(Vector inputs[], FunctionData *, idx_t input_count, Vector &state_vector,
86464
+ static void HistogramUpdateFunction(Vector inputs[], AggregateInputData &, idx_t input_count, Vector &state_vector,
86452
86465
  idx_t count) {
86453
86466
 
86454
86467
  D_ASSERT(input_count == 1);
@@ -86463,7 +86476,7 @@ static void HistogramUpdateFunction(Vector inputs[], FunctionData *, idx_t input
86463
86476
  }
86464
86477
 
86465
86478
  template <class T, class MAP_TYPE>
86466
- static void HistogramCombineFunction(Vector &state, Vector &combined, FunctionData *bind_data, idx_t count) {
86479
+ static void HistogramCombineFunction(Vector &state, Vector &combined, AggregateInputData &, idx_t count) {
86467
86480
 
86468
86481
  VectorData sdata;
86469
86482
  state.Orrify(count, sdata);
@@ -86488,7 +86501,8 @@ static void HistogramCombineFunction(Vector &state, Vector &combined, FunctionDa
86488
86501
  }
86489
86502
 
86490
86503
  template <class OP, class T, class MAP_TYPE>
86491
- static void HistogramFinalizeFunction(Vector &state_vector, FunctionData *, Vector &result, idx_t count, idx_t offset) {
86504
+ static void HistogramFinalizeFunction(Vector &state_vector, AggregateInputData &, Vector &result, idx_t count,
86505
+ idx_t offset) {
86492
86506
 
86493
86507
  VectorData sdata;
86494
86508
  state_vector.Orrify(count, sdata);
@@ -86676,7 +86690,8 @@ struct ListFunction {
86676
86690
  }
86677
86691
  };
86678
86692
 
86679
- static void ListUpdateFunction(Vector inputs[], FunctionData *, idx_t input_count, Vector &state_vector, idx_t count) {
86693
+ static void ListUpdateFunction(Vector inputs[], AggregateInputData &, idx_t input_count, Vector &state_vector,
86694
+ idx_t count) {
86680
86695
  D_ASSERT(input_count == 1);
86681
86696
 
86682
86697
  auto &input = inputs[0];
@@ -86700,7 +86715,7 @@ static void ListUpdateFunction(Vector inputs[], FunctionData *, idx_t input_coun
86700
86715
  }
86701
86716
  }
86702
86717
 
86703
- static void ListCombineFunction(Vector &state, Vector &combined, FunctionData *bind_data, idx_t count) {
86718
+ static void ListCombineFunction(Vector &state, Vector &combined, AggregateInputData &, idx_t count) {
86704
86719
  VectorData sdata;
86705
86720
  state.Orrify(count, sdata);
86706
86721
  auto states_ptr = (ListAggState **)sdata.data;
@@ -86723,7 +86738,7 @@ static void ListCombineFunction(Vector &state, Vector &combined, FunctionData *b
86723
86738
  }
86724
86739
  }
86725
86740
 
86726
- static void ListFinalize(Vector &state_vector, FunctionData *, Vector &result, idx_t count, idx_t offset) {
86741
+ static void ListFinalize(Vector &state_vector, AggregateInputData &, Vector &result, idx_t count, idx_t offset) {
86727
86742
  VectorData sdata;
86728
86743
  state_vector.Orrify(count, sdata);
86729
86744
  auto states = (ListAggState **)sdata.data;
@@ -86854,13 +86869,13 @@ struct RegrAvgFunction {
86854
86869
  }
86855
86870
 
86856
86871
  template <class STATE, class OP>
86857
- static void Combine(const STATE &source, STATE *target, FunctionData *bind_data) {
86872
+ static void Combine(const STATE &source, STATE *target, AggregateInputData &) {
86858
86873
  target->sum += source.sum;
86859
86874
  target->count += source.count;
86860
86875
  }
86861
86876
 
86862
86877
  template <class T, class STATE>
86863
- static void Finalize(Vector &result, FunctionData *, STATE *state, T *target, ValidityMask &mask, idx_t idx) {
86878
+ static void Finalize(Vector &result, AggregateInputData &, STATE *state, T *target, ValidityMask &mask, idx_t idx) {
86864
86879
  if (state->count == 0) {
86865
86880
  mask.SetInvalid(idx);
86866
86881
  } else {
@@ -86873,7 +86888,7 @@ struct RegrAvgFunction {
86873
86888
  };
86874
86889
  struct RegrAvgXFunction : RegrAvgFunction {
86875
86890
  template <class A_TYPE, class B_TYPE, class STATE, class OP>
86876
- static void Operation(STATE *state, FunctionData *bind_data, A_TYPE *x_data, B_TYPE *y_data, ValidityMask &amask,
86891
+ static void Operation(STATE *state, AggregateInputData &, A_TYPE *x_data, B_TYPE *y_data, ValidityMask &amask,
86877
86892
  ValidityMask &bmask, idx_t xidx, idx_t yidx) {
86878
86893
  state->sum += y_data[yidx];
86879
86894
  state->count++;
@@ -86882,7 +86897,7 @@ struct RegrAvgXFunction : RegrAvgFunction {
86882
86897
 
86883
86898
  struct RegrAvgYFunction : RegrAvgFunction {
86884
86899
  template <class A_TYPE, class B_TYPE, class STATE, class OP>
86885
- static void Operation(STATE *state, FunctionData *bind_data, A_TYPE *x_data, B_TYPE *y_data, ValidityMask &amask,
86900
+ static void Operation(STATE *state, AggregateInputData &, A_TYPE *x_data, B_TYPE *y_data, ValidityMask &amask,
86886
86901
  ValidityMask &bmask, idx_t xidx, idx_t yidx) {
86887
86902
  state->sum += x_data[xidx];
86888
86903
  state->count++;
@@ -86932,19 +86947,19 @@ struct RegrCountFunction {
86932
86947
  }
86933
86948
 
86934
86949
  template <class STATE, class OP>
86935
- static void Combine(const STATE &source, STATE *target, FunctionData *bind_data) {
86950
+ static void Combine(const STATE &source, STATE *target, AggregateInputData &) {
86936
86951
  *target += source;
86937
86952
  }
86938
86953
 
86939
86954
  template <class T, class STATE>
86940
- static void Finalize(Vector &result, FunctionData *, STATE *state, T *target, ValidityMask &mask, idx_t idx) {
86955
+ static void Finalize(Vector &result, AggregateInputData &, STATE *state, T *target, ValidityMask &mask, idx_t idx) {
86941
86956
  target[idx] = *state;
86942
86957
  }
86943
86958
  static bool IgnoreNull() {
86944
86959
  return true;
86945
86960
  }
86946
86961
  template <class A_TYPE, class B_TYPE, class STATE, class OP>
86947
- static void Operation(STATE *state, FunctionData *bind_data, A_TYPE *x_data, B_TYPE *y_data, ValidityMask &amask,
86962
+ static void Operation(STATE *state, AggregateInputData &, A_TYPE *x_data, B_TYPE *y_data, ValidityMask &amask,
86948
86963
  ValidityMask &bmask, idx_t xidx, idx_t yidx) {
86949
86964
  *state += 1;
86950
86965
  }
@@ -86994,21 +87009,21 @@ struct RegrSlopeOperation {
86994
87009
  }
86995
87010
 
86996
87011
  template <class A_TYPE, class B_TYPE, class STATE, class OP>
86997
- static void Operation(STATE *state, FunctionData *bind_data, A_TYPE *x_data, B_TYPE *y_data, ValidityMask &amask,
86998
- ValidityMask &bmask, idx_t xidx, idx_t yidx) {
86999
- CovarOperation::Operation<A_TYPE, B_TYPE, CovarState, OP>(&state->cov_pop, bind_data, y_data, x_data, bmask,
87000
- amask, yidx, xidx);
87001
- STDDevBaseOperation::Operation<A_TYPE, StddevState, OP>(&state->var_pop, bind_data, y_data, bmask, yidx);
87012
+ static void Operation(STATE *state, AggregateInputData &aggr_input_data, A_TYPE *x_data, B_TYPE *y_data,
87013
+ ValidityMask &amask, ValidityMask &bmask, idx_t xidx, idx_t yidx) {
87014
+ CovarOperation::Operation<A_TYPE, B_TYPE, CovarState, OP>(&state->cov_pop, aggr_input_data, y_data, x_data,
87015
+ bmask, amask, yidx, xidx);
87016
+ STDDevBaseOperation::Operation<A_TYPE, StddevState, OP>(&state->var_pop, aggr_input_data, y_data, bmask, yidx);
87002
87017
  }
87003
87018
 
87004
87019
  template <class STATE, class OP>
87005
- static void Combine(const STATE &source, STATE *target, FunctionData *bind_data) {
87006
- CovarOperation::Combine<CovarState, OP>(source.cov_pop, &target->cov_pop, bind_data);
87007
- STDDevBaseOperation::Combine<StddevState, OP>(source.var_pop, &target->var_pop, bind_data);
87020
+ static void Combine(const STATE &source, STATE *target, AggregateInputData &aggr_input_data) {
87021
+ CovarOperation::Combine<CovarState, OP>(source.cov_pop, &target->cov_pop, aggr_input_data);
87022
+ STDDevBaseOperation::Combine<StddevState, OP>(source.var_pop, &target->var_pop, aggr_input_data);
87008
87023
  }
87009
87024
 
87010
87025
  template <class T, class STATE>
87011
- static void Finalize(Vector &result, FunctionData *, STATE *state, T *target, ValidityMask &mask, idx_t idx) {
87026
+ static void Finalize(Vector &result, AggregateInputData &, STATE *state, T *target, ValidityMask &mask, idx_t idx) {
87012
87027
  if (state->cov_pop.count == 0 || state->var_pop.count == 0) {
87013
87028
  mask.SetInvalid(idx);
87014
87029
  } else {
@@ -87052,30 +87067,31 @@ struct RegrInterceptOperation {
87052
87067
  }
87053
87068
 
87054
87069
  template <class A_TYPE, class B_TYPE, class STATE, class OP>
87055
- static void Operation(STATE *state, FunctionData *bind_data, A_TYPE *x_data, B_TYPE *y_data, ValidityMask &amask,
87056
- ValidityMask &bmask, idx_t xidx, idx_t yidx) {
87070
+ static void Operation(STATE *state, AggregateInputData &aggr_input_data, A_TYPE *x_data, B_TYPE *y_data,
87071
+ ValidityMask &amask, ValidityMask &bmask, idx_t xidx, idx_t yidx) {
87057
87072
  state->count++;
87058
87073
  state->sum_x += y_data[yidx];
87059
87074
  state->sum_y += x_data[xidx];
87060
- RegrSlopeOperation::Operation<A_TYPE, B_TYPE, RegrSlopeState, OP>(&state->slope, bind_data, x_data, y_data,
87061
- amask, bmask, xidx, yidx);
87075
+ RegrSlopeOperation::Operation<A_TYPE, B_TYPE, RegrSlopeState, OP>(&state->slope, aggr_input_data, x_data,
87076
+ y_data, amask, bmask, xidx, yidx);
87062
87077
  }
87063
87078
 
87064
87079
  template <class STATE, class OP>
87065
- static void Combine(const STATE &source, STATE *target, FunctionData *bind_data) {
87080
+ static void Combine(const STATE &source, STATE *target, AggregateInputData &aggr_input_data) {
87066
87081
  target->count += source.count;
87067
87082
  target->sum_x += source.sum_x;
87068
87083
  target->sum_y += source.sum_y;
87069
- RegrSlopeOperation::Combine<RegrSlopeState, OP>(source.slope, &target->slope, bind_data);
87084
+ RegrSlopeOperation::Combine<RegrSlopeState, OP>(source.slope, &target->slope, aggr_input_data);
87070
87085
  }
87071
87086
 
87072
87087
  template <class T, class STATE>
87073
- static void Finalize(Vector &result, FunctionData *fd, STATE *state, T *target, ValidityMask &mask, idx_t idx) {
87088
+ static void Finalize(Vector &result, AggregateInputData &aggr_input_data, STATE *state, T *target,
87089
+ ValidityMask &mask, idx_t idx) {
87074
87090
  if (state->count == 0) {
87075
87091
  mask.SetInvalid(idx);
87076
87092
  return;
87077
87093
  }
87078
- RegrSlopeOperation::Finalize<T, RegrSlopeState>(result, fd, &state->slope, target, mask, idx);
87094
+ RegrSlopeOperation::Finalize<T, RegrSlopeState>(result, aggr_input_data, &state->slope, target, mask, idx);
87079
87095
  auto x_avg = state->sum_x / state->count;
87080
87096
  auto y_avg = state->sum_y / state->count;
87081
87097
  target[idx] = y_avg - target[idx] * x_avg;
@@ -87121,23 +87137,26 @@ struct RegrR2Operation {
87121
87137
  }
87122
87138
 
87123
87139
  template <class A_TYPE, class B_TYPE, class STATE, class OP>
87124
- static void Operation(STATE *state, FunctionData *bind_data, A_TYPE *x_data, B_TYPE *y_data, ValidityMask &amask,
87125
- ValidityMask &bmask, idx_t xidx, idx_t yidx) {
87126
- CorrOperation::Operation<A_TYPE, B_TYPE, CorrState, OP>(&state->corr, bind_data, y_data, x_data, bmask, amask,
87127
- yidx, xidx);
87128
- STDDevBaseOperation::Operation<A_TYPE, StddevState, OP>(&state->var_pop_x, bind_data, y_data, bmask, yidx);
87129
- STDDevBaseOperation::Operation<A_TYPE, StddevState, OP>(&state->var_pop_y, bind_data, x_data, amask, xidx);
87140
+ static void Operation(STATE *state, AggregateInputData &aggr_input_data, A_TYPE *x_data, B_TYPE *y_data,
87141
+ ValidityMask &amask, ValidityMask &bmask, idx_t xidx, idx_t yidx) {
87142
+ CorrOperation::Operation<A_TYPE, B_TYPE, CorrState, OP>(&state->corr, aggr_input_data, y_data, x_data, bmask,
87143
+ amask, yidx, xidx);
87144
+ STDDevBaseOperation::Operation<A_TYPE, StddevState, OP>(&state->var_pop_x, aggr_input_data, y_data, bmask,
87145
+ yidx);
87146
+ STDDevBaseOperation::Operation<A_TYPE, StddevState, OP>(&state->var_pop_y, aggr_input_data, x_data, amask,
87147
+ xidx);
87130
87148
  }
87131
87149
 
87132
87150
  template <class STATE, class OP>
87133
- static void Combine(const STATE &source, STATE *target, FunctionData *bind_data) {
87134
- CorrOperation::Combine<CorrState, OP>(source.corr, &target->corr, bind_data);
87135
- STDDevBaseOperation::Combine<StddevState, OP>(source.var_pop_x, &target->var_pop_x, bind_data);
87136
- STDDevBaseOperation::Combine<StddevState, OP>(source.var_pop_y, &target->var_pop_y, bind_data);
87151
+ static void Combine(const STATE &source, STATE *target, AggregateInputData &aggr_input_data) {
87152
+ CorrOperation::Combine<CorrState, OP>(source.corr, &target->corr, aggr_input_data);
87153
+ STDDevBaseOperation::Combine<StddevState, OP>(source.var_pop_x, &target->var_pop_x, aggr_input_data);
87154
+ STDDevBaseOperation::Combine<StddevState, OP>(source.var_pop_y, &target->var_pop_y, aggr_input_data);
87137
87155
  }
87138
87156
 
87139
87157
  template <class T, class STATE>
87140
- static void Finalize(Vector &result, FunctionData *fd, STATE *state, T *target, ValidityMask &mask, idx_t idx) {
87158
+ static void Finalize(Vector &result, AggregateInputData &aggr_input_data, STATE *state, T *target,
87159
+ ValidityMask &mask, idx_t idx) {
87141
87160
  auto var_pop_x = state->var_pop_x.count > 1 ? (state->var_pop_x.dsquared / state->var_pop_x.count) : 0;
87142
87161
  if (!Value::DoubleIsFinite(var_pop_x)) {
87143
87162
  throw OutOfRangeException("VARPOP(X) is out of range!");
@@ -87154,7 +87173,7 @@ struct RegrR2Operation {
87154
87173
  target[idx] = 1;
87155
87174
  return;
87156
87175
  }
87157
- CorrOperation::Finalize<T, CorrState>(result, fd, &state->corr, target, mask, idx);
87176
+ CorrOperation::Finalize<T, CorrState>(result, aggr_input_data, &state->corr, target, mask, idx);
87158
87177
  target[idx] = pow(target[idx], 2);
87159
87178
  }
87160
87179
 
@@ -87216,13 +87235,14 @@ struct RegrBaseOperation {
87216
87235
  }
87217
87236
 
87218
87237
  template <class STATE, class OP>
87219
- static void Combine(const STATE &source, STATE *target, FunctionData *bind_data) {
87220
- RegrCountFunction::Combine<size_t, OP>(source.count, &target->count, bind_data);
87221
- STDDevBaseOperation::Combine<StddevState, OP>(source.var_pop, &target->var_pop, bind_data);
87238
+ static void Combine(const STATE &source, STATE *target, AggregateInputData &aggr_input_data) {
87239
+ RegrCountFunction::Combine<size_t, OP>(source.count, &target->count, aggr_input_data);
87240
+ STDDevBaseOperation::Combine<StddevState, OP>(source.var_pop, &target->var_pop, aggr_input_data);
87222
87241
  }
87223
87242
 
87224
87243
  template <class T, class STATE>
87225
- static void Finalize(Vector &result, FunctionData *fd, STATE *state, T *target, ValidityMask &mask, idx_t idx) {
87244
+ static void Finalize(Vector &result, AggregateInputData &aggr_input_data, STATE *state, T *target,
87245
+ ValidityMask &mask, idx_t idx) {
87226
87246
  if (state->var_pop.count == 0) {
87227
87247
  mask.SetInvalid(idx);
87228
87248
  return;
@@ -87231,7 +87251,7 @@ struct RegrBaseOperation {
87231
87251
  if (!Value::DoubleIsFinite(var_pop)) {
87232
87252
  throw OutOfRangeException("VARPOP is out of range!");
87233
87253
  }
87234
- RegrCountFunction::Finalize<T, size_t>(result, fd, &state->count, target, mask, idx);
87254
+ RegrCountFunction::Finalize<T, size_t>(result, aggr_input_data, &state->count, target, mask, idx);
87235
87255
  target[idx] *= var_pop;
87236
87256
  }
87237
87257
 
@@ -87242,21 +87262,21 @@ struct RegrBaseOperation {
87242
87262
 
87243
87263
  struct RegrSXXOperation : RegrBaseOperation {
87244
87264
  template <class A_TYPE, class B_TYPE, class STATE, class OP>
87245
- static void Operation(STATE *state, FunctionData *bind_data, A_TYPE *x_data, B_TYPE *y_data, ValidityMask &amask,
87246
- ValidityMask &bmask, idx_t xidx, idx_t yidx) {
87247
- RegrCountFunction::Operation<A_TYPE, B_TYPE, size_t, OP>(&state->count, bind_data, y_data, x_data, bmask, amask,
87248
- yidx, xidx);
87249
- STDDevBaseOperation::Operation<A_TYPE, StddevState, OP>(&state->var_pop, bind_data, y_data, bmask, yidx);
87265
+ static void Operation(STATE *state, AggregateInputData &aggr_input_data, A_TYPE *x_data, B_TYPE *y_data,
87266
+ ValidityMask &amask, ValidityMask &bmask, idx_t xidx, idx_t yidx) {
87267
+ RegrCountFunction::Operation<A_TYPE, B_TYPE, size_t, OP>(&state->count, aggr_input_data, y_data, x_data, bmask,
87268
+ amask, yidx, xidx);
87269
+ STDDevBaseOperation::Operation<A_TYPE, StddevState, OP>(&state->var_pop, aggr_input_data, y_data, bmask, yidx);
87250
87270
  }
87251
87271
  };
87252
87272
 
87253
87273
  struct RegrSYYOperation : RegrBaseOperation {
87254
87274
  template <class A_TYPE, class B_TYPE, class STATE, class OP>
87255
- static void Operation(STATE *state, FunctionData *bind_data, A_TYPE *x_data, B_TYPE *y_data, ValidityMask &amask,
87256
- ValidityMask &bmask, idx_t xidx, idx_t yidx) {
87257
- RegrCountFunction::Operation<A_TYPE, B_TYPE, size_t, OP>(&state->count, bind_data, y_data, x_data, bmask, amask,
87258
- yidx, xidx);
87259
- STDDevBaseOperation::Operation<A_TYPE, StddevState, OP>(&state->var_pop, bind_data, x_data, bmask, xidx);
87275
+ static void Operation(STATE *state, AggregateInputData &aggr_input_data, A_TYPE *x_data, B_TYPE *y_data,
87276
+ ValidityMask &amask, ValidityMask &bmask, idx_t xidx, idx_t yidx) {
87277
+ RegrCountFunction::Operation<A_TYPE, B_TYPE, size_t, OP>(&state->count, aggr_input_data, y_data, x_data, bmask,
87278
+ amask, yidx, xidx);
87279
+ STDDevBaseOperation::Operation<A_TYPE, StddevState, OP>(&state->var_pop, aggr_input_data, x_data, bmask, xidx);
87260
87280
  }
87261
87281
  };
87262
87282
 
@@ -87297,25 +87317,26 @@ struct RegrSXYOperation {
87297
87317
  }
87298
87318
 
87299
87319
  template <class A_TYPE, class B_TYPE, class STATE, class OP>
87300
- static void Operation(STATE *state, FunctionData *bind_data, A_TYPE *x_data, B_TYPE *y_data, ValidityMask &amask,
87301
- ValidityMask &bmask, idx_t xidx, idx_t yidx) {
87302
- RegrCountFunction::Operation<A_TYPE, B_TYPE, size_t, OP>(&state->count, bind_data, y_data, x_data, bmask, amask,
87303
- yidx, xidx);
87304
- CovarOperation::Operation<A_TYPE, B_TYPE, CovarState, OP>(&state->cov_pop, bind_data, x_data, y_data, amask,
87305
- bmask, xidx, yidx);
87320
+ static void Operation(STATE *state, AggregateInputData &aggr_input_data, A_TYPE *x_data, B_TYPE *y_data,
87321
+ ValidityMask &amask, ValidityMask &bmask, idx_t xidx, idx_t yidx) {
87322
+ RegrCountFunction::Operation<A_TYPE, B_TYPE, size_t, OP>(&state->count, aggr_input_data, y_data, x_data, bmask,
87323
+ amask, yidx, xidx);
87324
+ CovarOperation::Operation<A_TYPE, B_TYPE, CovarState, OP>(&state->cov_pop, aggr_input_data, x_data, y_data,
87325
+ amask, bmask, xidx, yidx);
87306
87326
  }
87307
87327
 
87308
87328
  template <class STATE, class OP>
87309
- static void Combine(const STATE &source, STATE *target, FunctionData *bind_data) {
87310
- CovarOperation::Combine<CovarState, OP>(source.cov_pop, &target->cov_pop, bind_data);
87311
- RegrCountFunction::Combine<size_t, OP>(source.count, &target->count, bind_data);
87329
+ static void Combine(const STATE &source, STATE *target, AggregateInputData &aggr_input_data) {
87330
+ CovarOperation::Combine<CovarState, OP>(source.cov_pop, &target->cov_pop, aggr_input_data);
87331
+ RegrCountFunction::Combine<size_t, OP>(source.count, &target->count, aggr_input_data);
87312
87332
  }
87313
87333
 
87314
87334
  template <class T, class STATE>
87315
- static void Finalize(Vector &result, FunctionData *fd, STATE *state, T *target, ValidityMask &mask, idx_t idx) {
87316
- CovarPopOperation::Finalize<T, CovarState>(result, fd, &state->cov_pop, target, mask, idx);
87335
+ static void Finalize(Vector &result, AggregateInputData &aggr_input_data, STATE *state, T *target,
87336
+ ValidityMask &mask, idx_t idx) {
87337
+ CovarPopOperation::Finalize<T, CovarState>(result, aggr_input_data, &state->cov_pop, target, mask, idx);
87317
87338
  auto cov_pop = target[idx];
87318
- RegrCountFunction::Finalize<T, size_t>(result, fd, &state->count, target, mask, idx);
87339
+ RegrCountFunction::Finalize<T, size_t>(result, aggr_input_data, &state->count, target, mask, idx);
87319
87340
  target[idx] *= cov_pop;
87320
87341
  }
87321
87342
 
@@ -87465,9 +87486,9 @@ struct SortedAggregateFunction {
87465
87486
  sort_chunk.SetCardinality(count);
87466
87487
  }
87467
87488
 
87468
- static void SimpleUpdate(Vector inputs[], FunctionData *bind_data, idx_t input_count, data_ptr_t state,
87489
+ static void SimpleUpdate(Vector inputs[], AggregateInputData &aggr_input_data, idx_t input_count, data_ptr_t state,
87469
87490
  idx_t count) {
87470
- const auto order_bind = (SortedAggregateBindData *)bind_data;
87491
+ const auto order_bind = (SortedAggregateBindData *)aggr_input_data.bind_data;
87471
87492
  DataChunk arg_chunk;
87472
87493
  DataChunk sort_chunk;
87473
87494
  ProjectInputs(inputs, order_bind, input_count, count, arg_chunk, sort_chunk);
@@ -87477,14 +87498,14 @@ struct SortedAggregateFunction {
87477
87498
  order_state->ordering.Append(sort_chunk);
87478
87499
  }
87479
87500
 
87480
- static void ScatterUpdate(Vector inputs[], FunctionData *bind_data, idx_t input_count, Vector &states,
87501
+ static void ScatterUpdate(Vector inputs[], AggregateInputData &aggr_input_data, idx_t input_count, Vector &states,
87481
87502
  idx_t count) {
87482
87503
  if (!count) {
87483
87504
  return;
87484
87505
  }
87485
87506
 
87486
87507
  // Append the arguments to the two sub-collections
87487
- const auto order_bind = (SortedAggregateBindData *)bind_data;
87508
+ const auto order_bind = (SortedAggregateBindData *)aggr_input_data.bind_data;
87488
87509
  DataChunk arg_inputs;
87489
87510
  DataChunk sort_inputs;
87490
87511
  ProjectInputs(inputs, order_bind, input_count, count, arg_inputs, sort_inputs);
@@ -87529,7 +87550,7 @@ struct SortedAggregateFunction {
87529
87550
  }
87530
87551
 
87531
87552
  template <class STATE, class OP>
87532
- static void Combine(const STATE &source, STATE *target, FunctionData *bind_data) {
87553
+ static void Combine(const STATE &source, STATE *target, AggregateInputData &) {
87533
87554
  if (source.arguments.Count() == 0) {
87534
87555
  return;
87535
87556
  }
@@ -87537,8 +87558,9 @@ struct SortedAggregateFunction {
87537
87558
  target->ordering.Append(const_cast<ChunkCollection &>(source.ordering));
87538
87559
  }
87539
87560
 
87540
- static void Finalize(Vector &states, FunctionData *bind_data, Vector &result, idx_t count, idx_t offset) {
87541
- const auto order_bind = (SortedAggregateBindData *)bind_data;
87561
+ static void Finalize(Vector &states, AggregateInputData &aggr_input_data, Vector &result, idx_t count,
87562
+ idx_t offset) {
87563
+ const auto order_bind = (SortedAggregateBindData *)aggr_input_data.bind_data;
87542
87564
 
87543
87565
  // Reusable inner state
87544
87566
  vector<data_t> agg_state(order_bind->function.state_size());
@@ -87550,6 +87572,7 @@ struct SortedAggregateFunction {
87550
87572
  // State variables
87551
87573
  const auto input_count = order_bind->function.arguments.size();
87552
87574
  auto bind_info = order_bind->bind_info.get();
87575
+ AggregateInputData aggr_bind_info(bind_info);
87553
87576
 
87554
87577
  // Inner aggregate APIs
87555
87578
  auto initialize = order_bind->function.initialize;
@@ -87574,17 +87597,17 @@ struct SortedAggregateFunction {
87574
87597
  for (auto &chunk : state->arguments.Chunks()) {
87575
87598
  // These are all simple updates, so use it if available
87576
87599
  if (simple_update) {
87577
- simple_update(chunk->data.data(), bind_info, input_count, agg_state.data(), chunk->size());
87600
+ simple_update(chunk->data.data(), aggr_bind_info, input_count, agg_state.data(), chunk->size());
87578
87601
  } else {
87579
87602
  // We are only updating a constant state
87580
87603
  agg_state_vec.SetVectorType(VectorType::CONSTANT_VECTOR);
87581
- update(chunk->data.data(), bind_info, input_count, agg_state_vec, chunk->size());
87604
+ update(chunk->data.data(), aggr_bind_info, input_count, agg_state_vec, chunk->size());
87582
87605
  }
87583
87606
  }
87584
87607
 
87585
87608
  // Finalize a single value at the next offset
87586
87609
  agg_state_vec.SetVectorType(states.GetVectorType());
87587
- finalize(agg_state_vec, bind_info, result, 1, i + offset);
87610
+ finalize(agg_state_vec, aggr_bind_info, result, 1, i + offset);
87588
87611
 
87589
87612
  if (destructor) {
87590
87613
  destructor(agg_state_vec, 1);
@@ -95544,6 +95567,7 @@ static void ListAggregatesFunction(DataChunk &args, ExpressionState &state, Vect
95544
95567
  auto &func_expr = (BoundFunctionExpression &)state.expr;
95545
95568
  auto &info = (ListAggregatesBindData &)*func_expr.bind_info;
95546
95569
  auto &aggr = (BoundAggregateExpression &)*info.aggr_expr;
95570
+ AggregateInputData aggr_input_data(aggr.bind_info.get());
95547
95571
 
95548
95572
  D_ASSERT(aggr.function.update);
95549
95573
 
@@ -95601,7 +95625,7 @@ static void ListAggregatesFunction(DataChunk &args, ExpressionState &state, Vect
95601
95625
 
95602
95626
  // update the aggregate state(s)
95603
95627
  Vector slice = Vector(child_vector, sel_vector, states_idx);
95604
- aggr.function.update(&slice, aggr.bind_info.get(), 1, state_vector_update, states_idx);
95628
+ aggr.function.update(&slice, aggr_input_data, 1, state_vector_update, states_idx);
95605
95629
 
95606
95630
  // reset values
95607
95631
  states_idx = 0;
@@ -95617,12 +95641,12 @@ static void ListAggregatesFunction(DataChunk &args, ExpressionState &state, Vect
95617
95641
  // update the remaining elements of the last list(s)
95618
95642
  if (states_idx != 0) {
95619
95643
  Vector slice = Vector(child_vector, sel_vector, states_idx);
95620
- aggr.function.update(&slice, aggr.bind_info.get(), 1, state_vector_update, states_idx);
95644
+ aggr.function.update(&slice, aggr_input_data, 1, state_vector_update, states_idx);
95621
95645
  }
95622
95646
 
95623
95647
  if (IS_AGGR) {
95624
95648
  // finalize all the aggregate states
95625
- aggr.function.finalize(state_vector.state_vector, aggr.bind_info.get(), result, count, 0);
95649
+ aggr.function.finalize(state_vector.state_vector, aggr_input_data, result, count, 0);
95626
95650
 
95627
95651
  } else {
95628
95652
  // finalize manually to use the map
@@ -104752,7 +104776,8 @@ static void AggregateStateFinalize(DataChunk &input, ExpressionState &state_p, V
104752
104776
  state_vec_ptr[i] = (data_ptr_t)target_ptr;
104753
104777
  }
104754
104778
 
104755
- bind_data.aggr.finalize(local_state.addresses, nullptr, result, input.size(), 0);
104779
+ AggregateInputData aggr_input_data(nullptr);
104780
+ bind_data.aggr.finalize(local_state.addresses, aggr_input_data, result, input.size(), 0);
104756
104781
 
104757
104782
  for (idx_t i = 0; i < input.size(); i++) {
104758
104783
  auto state_idx = state_data.sel->get_index(i);
@@ -104815,7 +104840,8 @@ static void AggregateStateCombine(DataChunk &input, ExpressionState &state_p, Ve
104815
104840
  memcpy(local_state.state_buffer0.get(), state0.GetDataUnsafe(), bind_data.state_size);
104816
104841
  memcpy(local_state.state_buffer1.get(), state1.GetDataUnsafe(), bind_data.state_size);
104817
104842
 
104818
- bind_data.aggr.combine(local_state.state_vector0, local_state.state_vector1, nullptr, 1);
104843
+ AggregateInputData aggr_input_data(nullptr);
104844
+ bind_data.aggr.combine(local_state.state_vector0, local_state.state_vector1, aggr_input_data, 1);
104819
104845
 
104820
104846
  result_ptr[i] =
104821
104847
  StringVector::AddStringOrBlob(result, (const char *)local_state.state_buffer1.get(), bind_data.state_size);
@@ -104876,10 +104902,10 @@ static unique_ptr<FunctionData> BindAggregateState(ClientContext &context, Scala
104876
104902
  return make_unique<ExportAggregateBindData>(bound_aggr, bound_aggr.state_size());
104877
104903
  }
104878
104904
 
104879
- static void ExportAggregateFinalize(Vector &state, FunctionData *bind_data_p, Vector &result, idx_t count,
104905
+ static void ExportAggregateFinalize(Vector &state, AggregateInputData &aggr_input_data, Vector &result, idx_t count,
104880
104906
  idx_t offset) {
104881
104907
  D_ASSERT(offset == 0);
104882
- auto bind_data = (ExportAggregateFunctionBindData *)bind_data_p;
104908
+ auto bind_data = (ExportAggregateFunctionBindData *)aggr_input_data.bind_data;
104883
104909
  auto state_size = bind_data->aggregate->function.state_size();
104884
104910
  auto blob_ptr = FlatVector::GetData<string_t>(result);
104885
104911
  auto addresses_ptr = FlatVector::GetData<data_ptr_t>(state);