message: Implement fetch for constant segment
diff: @@ -78,13 +78,58 @@ void ConstantSegment::Scan(ColumnScanState &state, idx_t start, idx_t scan_count
  //===--------------------------------------------------------------------===//
  // Fetch Row
  //===--------------------------------------------------------------------===//
  +void FetchFunctionValidity(ConstantSegment &segment, Vector &result, idx_t result_idx) {
  + auto &validity = (ValidityStatistics &) *segment.stats.statistics;
  + if (validity.has_null) {
  + auto &mask = FlatVector::Validity(result);
  + mask.SetInvalid(result_idx);
  + }
  +}
  +
  +template<class T>
  +void FetchFunction(ConstantSegment &segment, Vector &result, idx_t result_idx) {
  + auto &nstats = (NumericStatistics &) *segment.stats.statistics;
  +
  + auto data = FlatVector::GetData<T>(result);
  + data[result_idx] = nstats.min.GetValueUnsafe<T>();
  +}
  +
  ConstantSegment::fetch_function_t GetFetchFunction(PhysicalType type) {
  - return nullptr;
  + switch (type) {
  + case PhysicalType::BIT:
  + return FetchFunctionValidity;
  + case PhysicalType::BOOL:
  + case PhysicalType::INT8:
  + return FetchFunction<int8_t>;
  + case PhysicalType::INT16:
  + return FetchFunction<int16_t>;
  + case PhysicalType::INT32:
  + return FetchFunction<int32_t>;
  + case PhysicalType::INT64:
  + return FetchFunction<int64_t>;
  + case PhysicalType::UINT8:
  + return FetchFunction<uint8_t>;
  + case PhysicalType::UINT16:
  + return FetchFunction<uint16_t>;
  + case PhysicalType::UINT32:
  + return FetchFunction<uint32_t>;
  + case PhysicalType::UINT64:
  + return FetchFunction<uint64_t>;
  + case PhysicalType::INT128:
  + return FetchFunction<hugeint_t>;
  + case PhysicalType::FLOAT:
  + return FetchFunction<float>;
  + case PhysicalType::DOUBLE:
  + return FetchFunction<double>;
  + case PhysicalType::INTERVAL:
  + return FetchFunction<interval_t>;
  + default:
  + throw NotImplementedException("Unimplemented type for constant segment");
  + }
  }
  void ConstantSegment::FetchRow(ColumnFetchState &state, row_t row_id, Vector &result, idx_t result_idx) {
  - throw InternalException("FIXME: constant fetch");
  - // fetch_function(*this, result, result_idx);
  + fetch_function(*this, result, result_idx);
  }
  //===--------------------------------------------------------------------===//
  