message: Correctly copy string to vector in mode window function for varchars
diff: @@ -122,7 +122,22 @@ struct ModeIncluded {
  const idx_t bias;
  };
  -template <typename KEY_TYPE>
  +
  +struct ModeAssignmentStandard {
  + template<class INPUT_TYPE, class RESULT_TYPE>
  + static RESULT_TYPE Assign(Vector &result, INPUT_TYPE input) {
  + return RESULT_TYPE(input);
  + }
  +};
  +
  +struct ModeAssignmentString {
  + template<class INPUT_TYPE, class RESULT_TYPE>
  + static RESULT_TYPE Assign(Vector &result, INPUT_TYPE input) {
  + return StringVector::AddString(result, input);
  + }
  +};
  +
  +template <typename KEY_TYPE, typename ASSIGN_OP>
  struct ModeFunction {
  template <class STATE>
  static void Initialize(STATE *state) {
  @@ -235,7 +250,7 @@ struct ModeFunction {
  }
  if (state->valid) {
  - rdata[rid] = RESULT_TYPE(*state->mode);
  + rdata[rid] = ASSIGN_OP::template Assign<INPUT_TYPE, RESULT_TYPE>(result, *state->mode);
  } else {
  rmask.Set(rid, false);
  }
  @@ -251,10 +266,10 @@ struct ModeFunction {
  }
  };
  -template <typename INPUT_TYPE, typename KEY_TYPE>
  +template <typename INPUT_TYPE, typename KEY_TYPE, typename ASSIGN_OP=ModeAssignmentStandard>
  AggregateFunction GetTypedModeFunction(const LogicalType &type) {
  using STATE = ModeState<KEY_TYPE>;
  - using OP = ModeFunction<KEY_TYPE>;
  + using OP = ModeFunction<KEY_TYPE, ASSIGN_OP>;
  auto func = AggregateFunction::UnaryAggregateDestructor<STATE, INPUT_TYPE, INPUT_TYPE, OP>(type, type);
  func.window = AggregateFunction::UnaryWindow<STATE, INPUT_TYPE, INPUT_TYPE, OP>;
  return func;
  @@ -290,7 +305,7 @@ AggregateFunction GetModeAggregate(const LogicalType &type) {
  return GetTypedModeFunction<interval_t, interval_t>(type);
  case PhysicalType::VARCHAR:
  - return GetTypedModeFunction<string_t, string>(type);
  + return GetTypedModeFunction<string_t, string, ModeAssignmentString>(type);
  default:
  throw NotImplementedException("Unimplemented mode aggregate");
  