[HDX-5077] Fix multi-series metric charts mixing float and int aggregations - #2916
[HDX-5077] Fix multi-series metric charts mixing float and int aggregations#2916wrn14897 wants to merge 1 commit into
Conversation
The HDX-5077 UNION ALL + pivot merge composed per-series value columns without normalizing their types. Series with no least supertype — e.g. histogram quantile (Float64) + histogram count (Int64) — either failed with NO_COMMON_TYPE (use_variant_as_common_type = 0) or produced Variant(Float64, Int64) output columns (the modern default), which no consumer classifies as numeric, surfacing as "No value columns found in result column metadata" in the app and CLI. Normalize every branch's __hdx_value to Float64 in the UNION wrappers so the merged type is deterministic regardless of server settings, matching the JS-number semantics of the old node-side merge. As a defensive second layer, convertCHDataTypeToJSType now classifies all-numeric Variant(...) columns as numeric (also helps raw-SQL charts).
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
🦋 Changeset detectedLatest commit: af180d7 The changes in this PR will be included in the next version bump. This PR includes changesets to release 4 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
🔵 Tier 2 — Low RiskSmall, isolated change with no API route or data model modifications. Why this tier:
Additional context: touches the query rendering engine lightly (32 lines, under the 150-line bar for Tier 4) Review process: AI review + quick human skim (target: 5–15 min). Reviewer validates AI assessment and checks for domain-specific concerns. Stats
|
Greptile SummaryFixes mixed integer/float multi-series metric queries by normalizing each UNION branch to Float64 and adds defensive handling for numeric ClickHouse Variant metadata.
Confidence Score: 4/5The primary multi-series normalization appears sound, but the advertised raw-SQL fallback should recognize Decimal-containing numeric Variants before merging. Mixed metric branches are normalized and exercised end to end, while the new Variant fallback still rejects valid all-numeric metadata whenever one member belongs to ClickHouse’s Decimal family. Files Needing Attention: packages/common-utils/src/clickhouse/index.ts, packages/common-utils/src/clickhouse/tests/index.test.ts
|
| Filename | Overview |
|---|---|
| packages/common-utils/src/core/renderChartConfig.ts | Normalizes scalar and histogram branch values to Float64 while preserving the positional schema required by the UNION and pivot. |
| packages/common-utils/src/clickhouse/index.ts | Adds numeric Variant handling, but valid Decimal members cause an otherwise all-numeric Variant to remain unclassified. |
| packages/common-utils/src/tests/queryChartConfig.int.test.ts | Adds end-to-end coverage for mixed native numeric types across histogram-only and scalar-plus-histogram branch combinations. |
| packages/common-utils/src/clickhouse/tests/index.test.ts | Covers integer/float, mixed, and empty Variants but omits Decimal-containing numeric Variants. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart LR
A[Metric series branches] --> B[toFloat64 normalization]
B --> C[UNION ALL]
C --> D[anyOrNullIf pivot]
D --> E[Float64 chart value columns]
F[Raw SQL Variant metadata] --> G[Recursive member classification]
G -->|Int UInt Float| H[Numeric value column]
G -->|Decimal member| I[Column remains unclassified]
Reviews (1): Last reviewed commit: "fix: multi-series metric charts mixing f..." | Re-trigger Greptile
| memberType => | ||
| convertCHDataTypeToJSType(memberType) === JSDataType.Number, | ||
| ) | ||
| ) { |
There was a problem hiding this comment.
Decimal Variants Remain Unclassified
If a raw-SQL result has an all-numeric type such as Variant(Float64, Decimal(10, 2)), the recursive check returns null for the Decimal member and rejects the entire Variant, causing value-column inference to omit the column and the chart to report that no numeric value column exists.
E2E Test Results✅ All tests passed • 296 passed • 1 skipped • 1026s
Tests ran across 4 shards in parallel. |
Deep ReviewTargeted, well-scoped bug fix for multi-series metric tiles that mix float- and integer-producing aggregations. The core change (normalizing every UNION branch's value column to ✅ No critical issues found. 🟡 P2 — recommended
🔵 P3 nitpicks (1)
Reviewers (8): correctness, testing, maintainability, project-standards, performance, kieran-typescript, agent-native, learnings-researcher. Testing gaps:
|
Why
Fixes a regression introduced by HDX-5077 (#2859). Any multi-series metric tile mixing float- and integer-producing aggregations — e.g. histogram
quantile(Float64) + histogramcount(Int64) — fails to render with:Root cause
The composed UNION ALL + pivot query funnels every series through the shared
__hdx_valuecolumn without normalizing its type.Int64/UInt64have no least supertype withFloat64, so a mixed-type UNION either:NO_COMMON_TYPE(error 386) whenuse_variant_as_common_type = 0, orVariant(Float64, Int64)(the modern ClickHouse default), which theanyOrNullIfpivot propagates to every output column.convertCHDataTypeToJSTypehad noVariant(...)case, soinferValueColumnsfound no numeric columns in both the app and CLI.The HDX-5076 regression baseline only covered same-typed series (all branches Float64), so this combination slipped through.
What
Primary fix (
renderMultiSeriesMetricChartConfig): every branch wrapper normalizes the value column to Float64 —SELECT * REPLACE (toFloat64(`__hdx_value`) AS `__hdx_value`), …(preserves group-column names/positions)toFloat64(`__hdx_value`) AS `__hdx_value`The merged type is now deterministically
Float64/Nullable(Float64)regardless of server settings, matching the JS-number semantics of the old node-side merge.Defensive layer (
convertCHDataTypeToJSType): all-numericVariant(...)columns are now classified as numeric, so raw-SQL charts hitting the same server behavior still render. Mixed variants stay unclassified.Tests
quantile+ histogramcount(the exact production repro) and gaugeavg+ histogramcount(covers the scalar* REPLACEwrapper path). Meta assertions pin the type toFloat64/Nullable(Float64)directly — deliberately not just viaconvertCHDataTypeToJSType, since the Variant fallback would otherwise mask a normalization regression on servers runninguse_variant_as_common_type = 0. Both fail without the fix and pass with it.Variant(...)classification.make ci-lint,make ci-unit, and the fullqueryChartConfigint suite (30 tests) all green.