fix: classify numeric columns as aggregation in readAsScalar#11471
Open
krsoninikhil wants to merge 1 commit into
Open
fix: classify numeric columns as aggregation in readAsScalar#11471krsoninikhil wants to merge 1 commit into
krsoninikhil wants to merge 1 commit into
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request
📄 Summary
readAsScalaronly recognised columns named__result_Nas aggregations. Any other name — including user-defined aliases likecount() AS total_requests— defaulted tocolumnType: "group". The frontend uses this field to split columns into labels vs values for pie charts and scalar panels, so custom aliases caused charts to show "No Data".The fix mirrors the fallback logic already present in
readAsTimeSeries: if a column doesn't match an explicit marker (__result_Nor a legacy alias likeresult/value), infer aggregation intent from the DB column's numeric type.Issues closed by this PR
Closes #8844
✅ Change Type
🐛 Bug Context
Root Cause
readAsScalarclassified columns purely by name regex (^__result_(\d+)$).readAsTimeSerieshad a fuller fallback chain (single numeric column, legacy aliases) butreadAsScalarnever received the same treatment.Fix Strategy
Add two fallback conditions to
readAsScalar, in priority order:legacyReservedColumnTargetAliases(result,value,res, …) → aggregationExplicit
__result_Nmarkers still take priority, so all existing queries are unaffected.🧪 Testing Strategy
count() AS total_requestsnow renders correctly;count() AS __result_0continues to work.__result_0+ custom alias), legacy aliases, string-only group columns.readAsScalaronly — time-series and raw query paths are untouched.consume.go.📝 Changelog
📋 Checklist
👀 Notes for Reviewers
The change is 5 lines in
readAsScalar. The key insight:readAsTimeSeriesalready had this fallback logic butreadAsScalarnever did. The fix brings them in line with each other.