Compare commits

...

1 Commits

Author SHA1 Message Date
Nikhil Soni
6a7a1b870e fix: classify numeric columns as aggregation in readAsScalar
Pie charts and scalar panels break when ClickHouse queries use custom
aggregation aliases (e.g. `count() AS total_requests`) because
readAsScalar only recognised __result_N pattern columns as aggregations,
returning columnType "group" for everything else.

Apply the same fallback logic already used in readAsTimeSeries: if a
column doesn't match an explicit marker (__result_N or a legacy alias),
infer aggregation from numeric DB type.

Closes #8844

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-27 11:39:35 +05:30

View File

@@ -292,6 +292,11 @@ func readAsScalar(rows driver.Rows, queryName string) (*qbtypes.ScalarData, erro
colType := qbtypes.ColumnTypeGroup
if aggRe.MatchString(name) {
colType = qbtypes.ColumnTypeAggregation
} else if slices.Contains(legacyReservedColumnTargetAliases, name) {
colType = qbtypes.ColumnTypeAggregation
} else if numericKind(colTypes[i].ScanType().Kind()) {
// Custom alias or unnamed aggregation: infer from numeric type.
colType = qbtypes.ColumnTypeAggregation
}
cd[i] = &qbtypes.ColumnDescriptor{
TelemetryFieldKey: telemetrytypes.TelemetryFieldKey{Name: name},