Repository: duckdb/duckdb
File: src/include/duckdb/main/query_profiler.hpp (C++)

Code before:
class PhysicalOperator;
class SQLStatement;
struct ActiveTimer;

enum class ProfilingCoverage : uint8_t { SELECT = 0, ALL = 1 };

struct OperatorInformation {
	explicit OperatorInformation() {
	}

	string name;

	double time = 0;
	idx_t elements_returned = 0;
	idx_t result_set_size = 0;
	idx_t system_peak_buffer_manager_memory = 0;
	idx_t system_peak_temp_directory_size = 0;
	idx_t rows_scanned = 0;

	InsertionOrderPreservingMap<string> extra_info;

	template <typename T>
	void AddMetric(MetricType type, T metric) {
		switch (type) {
		case MetricType::OPERATOR_TIMING:
			time += LossyNumericCast<idx_t>(metric);
			break;
		case MetricType::OPERATOR_CARDINALITY:
			elements_returned += LossyNumericCast<idx_t>(metric);
			break;
		case MetricType::RESULT_SET_SIZE:
			result_set_size += LossyNumericCast<idx_t>(metric);
			break;
		case MetricType::SYSTEM_PEAK_BUFFER_MEMORY: {
			if (metric > system_peak_buffer_manager_memory) {
				system_peak_buffer_manager_memory += LossyNumericCast<idx_t>(metric);
			}
			break;
		}
		case MetricType::SYSTEM_PEAK_TEMP_DIR_SIZE: {
			if (metric > system_peak_temp_directory_size) {
				system_peak_temp_directory_size = LossyNumericCast<idx_t>(metric);
			}
			break;
		}
		case MetricType::OPERATOR_ROWS_SCANNED:
			rows_scanned = LossyNumericCast<idx_t>(metric);
			break;
		default:
			throw InternalException("OperatorProfiler: Unknown metric type");
		}

Review comment (bug):
```sh
/Users/hjiang/Desktop/duckdb/src/include/duckdb/main/query_profiler.hpp:62:22: warning: implicit conversion turns floating-point number into integer: 'double' to 'idx_t' (aka 'unsigned long long') [-Wfloat-conversion]
   62 |                         elements_returned += metric;
      |                         ~~~~~~~~~~~~~~~~~~^~~~~~~~~
/Users/hjiang/Desktop/duckdb/src/main/query_profiler.cpp:399:9: note: in instantiation of function template specialization 'duckdb::OperatorInformation::AddMetric<double>' requested here
  399 |                         info.AddMetric(MetricType::OPERATOR_TIMING, op.Elapsed());
      |                              ^
In file included from /Users/hjiang/Desktop/duckdb/build/debug/src/main/ub_duckdb_main.cpp:2:
In file included from /Users/hjiang/Desktop/duckdb/src/main/appender.cpp:11:
In file included from /Users/hjiang/Desktop/duckdb/src/include/duckdb/main/client_context.hpp:21:
In file included from /Users/hjiang/Desktop/duckdb/src/include/duckdb/main/client_config.hpp:19:
/Users/hjiang/Desktop/duckdb/src/include/duckdb/main/query_profiler.hpp:65:20: warning: implicit conversion turns floating-point number into integer: 'double' to 'idx_t' (aka 'unsigned long long') [-Wfloat-conversion]
   65 |                         result_set_size += metric;
      |                         ~~~~~~~~~~~~~~~~^~~~~~~~~
/Users/hjiang/Desktop/duckdb/src/include/duckdb/main/query_profiler.hpp:69:39: warning: implicit conversion turns floating-point number into integer: 'double' to 'idx_t' (aka 'unsigned long long') [-Wfloat-conversion]
   69 |                                 system_peak_buffer_manager_memory += metric;
      |                                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~
/Users/hjiang/Desktop/duckdb/src/include/duckdb/main/query_profiler.hpp:75:39: warning: implicit conversion turns floating-point number into integer: 'double' to 'idx_t' (aka 'unsigned long long') [-Wfloat-conversion]
   75 |                                 system_peak_temp_directory_size = metric;
      |                                                                 ~ ^~~~~~
/Users/hjiang/Desktop/duckdb/src/include/duckdb/main/query_profiler.hpp:80:19: warning: implicit conversion turns floating-point number into integer: 'double' to 'idx_t' (aka 'unsigned long long') [-Wfloat-conversion]
   80 |                         rows_scanned = metric;
      |                                      ~ ^~~~~~
```

Code after:
class PhysicalOperator;
class SQLStatement;
struct ActiveTimer;

enum class ProfilingCoverage : uint8_t { SELECT = 0, ALL = 1 };

struct OperatorInformation {
	explicit OperatorInformation() {
	}

	string name;

	double time = 0;
	idx_t elements_returned = 0;
	idx_t result_set_size = 0;
	idx_t system_peak_buffer_manager_memory = 0;
	idx_t system_peak_temp_directory_size = 0;
	idx_t rows_scanned = 0;

	InsertionOrderPreservingMap<string> extra_info;

	template <typename T>
	void AddMetric(MetricType type, T metric) {
		switch (type) {
		case MetricType::OPERATOR_TIMING:
			time += metric;
			break;
		case MetricType::OPERATOR_CARDINALITY:
			elements_returned += LossyNumericCast<idx_t>(metric);
			break;
		case MetricType::RESULT_SET_SIZE:
			result_set_size += LossyNumericCast<idx_t>(metric);
			break;
		case MetricType::SYSTEM_PEAK_BUFFER_MEMORY: {
			if (metric > system_peak_buffer_manager_memory) {
				system_peak_buffer_manager_memory += LossyNumericCast<idx_t>(metric);
			}
			break;
		}
		case MetricType::SYSTEM_PEAK_TEMP_DIR_SIZE: {
			if (metric > system_peak_temp_directory_size) {
				system_peak_temp_directory_size = LossyNumericCast<idx_t>(metric);
			}
			break;
		}
		case MetricType::OPERATOR_ROWS_SCANNED:
			rows_scanned = LossyNumericCast<idx_t>(metric);
			break;
		default:
			throw InternalException("OperatorProfiler: Unknown metric type");
		}