Fix: Group By on ratio charts#2538
Conversation
🦋 Changeset detectedLatest commit: d7bc84b 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 |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
🟡 Tier 3 — StandardIntroduces new logic, modifies core functionality, or touches areas with non-trivial risk. Why this tier:
Review process: Full human review — logic, architecture, edge cases. Stats
|
Greptile SummaryThis PR fixes Group By behavior for ratio charts. The main changes are:
Confidence Score: 5/5This looks safe to merge.
Important Files Changed
Reviews (7): Last reviewed commit: "Merge branch 'main' into jordansimonovsk..." | Re-trigger Greptile |
E2E Test Results✅ All tests passed • 223 passed • 3 skipped • 1542s
Tests ran across 4 shards in parallel. |
Deep ReviewScope: Group By support for ratio charts — split-query merge/ratio logic in The happy path — a grouped ratio with string dimensions and two valid split result sets — is correct and well covered by the new unit tests. Findings below are edge-case robustness, one autocomplete reliability regression on the new intersect path, and test-coverage gaps. No data-corruption, crash, or security issue is introduced on the happy path. ✅ No critical (P0/P1) issues found. 🟡 P2 — recommended
🔵 P3 nitpicks (5)
Reviewers (6): correctness, adversarial, performance, testing, maintainability, kieran-typescript. Testing gaps:
Non-blocking notes: |
Problem
Ratio charts (As Ratio) couldn't be meaningfully grouped:
Root cause
Ratio runs the numerator and denominator as two separate queries and merges them. Two bugs:
Separately, metric sources have no single from.tableName (they fan out to per-type tables),input had no table to fetch attribute keys from.
Changes
packages/common-utils/src/clickhouse/index.ts
packages/app/src/components/DBEditTimeChartForm/ChartEditorControls.tsx
typing on metric ratio/multi-series charts — matching the per-series inputs. Non-metric sou
Why share-of-total
"Group by" applied to a ratio has two plausible meanings: each group's own rate (per-group)n to the overall rate (share-of-total). We chose share-of-total so a grouped error-rate
decomposes the blended rate — the lines add up to the number you see ungrouped — which matcdown the 22% by tenant" chart. (Per-group rates are still available by not using ratio mode,or via a future toggle if needed.)
Testing
Scope
Only affects metric ratio charts — the only config path that splits into the merge/ratio coatio or non-metric charts.