Repository navigation
fix(dashboard): resolve metric Label in Chart Data (View as table) results grid - #43719
Conversation
✅ Deploy Preview for superset-docs-preview ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
amaannawab923
left a comment
There was a problem hiding this comment.
Nice fix, and the diagnosis is exactly right. Tracing it through, createVerboseMap in hooks/apiResources/datasets.ts already merges both dataset.columns and dataset.metrics, and drill_info_select_columns on master selects no metrics at all, so dataset.metrics really was always undefined on the frontend. Good call fixing it at the API rather than working around it in the hook.
A few findings from going through it, none of which change the approach:
- The guest branch now returns every metric defined on the dataset rather than a scoped set. Left inline, and it is the one I would want a second opinion on.
- The filtering asymmetry between
columnsandmetricsis intentional but is not pinned by a test. - A small note on payload size for the per dashboard load path.
One other thing worth a rebase: #43390 touched this same schema after this branch was cut, adding PII exclusions on the grounds that drill_info is reachable by embedded guests through the dashboard fallback. That context reads directly onto the first point.
Code Review Agent Run #4d4a23Actionable Suggestions - 0Additional Suggestions - 1
Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
46a856a to
9cd0884
Compare
|
Pushed an update addressing all review threads (rebased onto master, so #43390's schema hardening is now on the branch). What changed since the last review The bigger half of the fix turned out to be on the frontend, per @msyavuz's and @EnxDev's comments: Also added tests pinning the deliberate On the Bito note about Verification
Full local runs: 145 frontend tests across 17 suites ( |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #43719 +/- ##
==========================================
+ Coverage 79.31% 79.37% +0.05%
==========================================
Files 2889 2891 +2
Lines 166880 167584 +704
Branches 38660 38741 +81
==========================================
+ Hits 132360 133018 +658
- Misses 32027 32067 +40
- Partials 2493 2499 +6
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
msyavuz
left a comment
There was a problem hiding this comment.
Gating fix works — can_get_drill_info is in READ_ONLY_PERMISSION, so default Gamma holds it and the can_view_chart_as_table-only path now fetches. Two residual gaps of the same shape.
9cd0884 to
bf2866b
Compare
|
Second round pushed — thanks @msyavuz and @EnxDev, both of these changed the shape of the fix. @msyavuz's second point reframed the bug. It isn't "metrics are missing from Two things I'd rather flag than bury:
@EnxDev found a genuine regression in the first round's fix: adding metrics to a flat map let an unused metric relabel a column the chart actually selected. Verification (each new test verified failing against the previous code first):
Full runs: 279 frontend tests across 33 suites ( |
bf2866b to
10ba56a
Compare
|
Follow-up on the payload/perf question with measurements instead of reasoning, @amaannawab923 — including a correction to something I asserted in that thread. Database cost: one extra
The extra one is the eager load of Correction: no new requests for any default role. I wrote that this PR "increases who fetches
One cost that is real, from @EnxDev's extension finding after that thread was resolved: where Permissions: no boundary moves. Route gate unchanged ( All of the above is now summarised in the PR description so it isn't buried in resolved threads. |
Code Review Agent Run #a15641Actionable Suggestions - 0Additional Suggestions - 1
Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
…results grid On a dashboard, opening a chart's context menu -> "View as table" showed raw technical names (e.g. sum__num) as results-grid column headers instead of the friendly Labels (verbose_name) the chart itself renders. Backend: GET /api/v1/dataset/<pk>/drill_info/ selected only columns and narrowed them to groupby=True, and DatasetDrillInfoSchema had no metrics field. That response is also the source of the verbose map for the results grid, so metrics and non-dimension columns -- which a raw-records table routinely selects -- had no label to resolve to. Return both lists whole, with each column carrying its groupby flag so the drill-by picker can narrow to dimensions client-side, which is the only consumer that needs it. Frontend: SliceHeaderControls passed !canDrillToDetail as useDatasetDrillInfo's skip, so a user who has "View as table" but not Drill to detail -- including the default Gamma role -- never fetched drill_info and still saw raw names. The menu entry and the fetch that feeds its headers now share one predicate so they cannot drift, guarded by can_get_drill_info so a role without dataset read access does not fire a request that can only 403. ChartContextMenu filters drill-by options by column.groupby, which it already did on the extension path. createVerboseMap writes metrics before columns so a column wins a name collision, matching SqlaTable.data_for_slices -- otherwise an unused metric could relabel a column the chart actually selected. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
10ba56a to
6e8b077
Compare
|
Bito's run #a15641 caught a real one, so noting it here rather than letting it sit as an unactioned bot suggestion. The extension fallback I added for @EnxDev's finding routed a handled failure through the shared // `bestEffort` callers recover from a failure themselves, so it is not worth
// logging: a deployment that registers the drill-by extension because this
// endpoint is unreachable would otherwise log on every dashboard load.
const fetchDrillInfo = async ({ bestEffort = false } = {}) => {
...
} catch (error) {
if (!bestEffort) {
logging.error('Failed to load dataset: ', error);
}
supersetGetCache.delete(endpoint);
throw error;
}
};The cache eviction and the rethrow stay on both paths — only the log is suppressed, and only for the caller that handles the error itself. Where the API is the sole label source, a failure is still fatal and still logged. Two tests, one per branch, so the distinction can't erode:
The first fails against the previous commit. 282 passing across 33 suites, pre-commit green. For the record on the other bot item from run #4d4a23 — extracting a shared base for |
Code Review Agent Run #7e41baActionable Suggestions - 0Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
We should all start having our myriad review-bots "request changes" to spare people like me from merging green PRs that are actually awaiting fixes to be mergeable. |
SUMMARY
On a dashboard, opening a chart's context menu → "View as table" (the Chart Data modal,
ResultsPaneOnDashboard) showed raw technical names (e.g.sum__num) as results-grid column headers instead of the friendly Labels (verbose_name), even though the chart itself rendered the Labels correctly and even for a full-permission Admin user.There were two independent causes, one on each side.
Backend. The results-grid header comes from
columnDisplayNames?.[key] ?? keyinuseGridResultTable, fed bydatasetWithVerboseMap?.verbose_mapinSliceHeaderControls, whichcreateVerboseMapbuilds fromGET /api/v1/dataset/<pk>/drill_info/. That endpoint was purpose-built for the Drill-to-Detail "drill by" dimension picker, so it selected onlycolumnsand narrowed them togroupby=True, andDatasetDrillInfoSchemahad nometricsfield at all. Once it was also used as the source of the results grid's verbose map, everything it dropped for the picker's benefit lost its label: every metric, and every non-dimension column — which a raw-records table routinely selects.Fix: return both lists whole.
metrics.metric_name/metrics.verbose_nameare added to the select columns and ametricsfield (via a newDatasetMetricDrillInfoSchema) to the schema; thepost_dumpnarrowing ofcolumnsis removed and each column carries itsgroupbyflag instead, so the drill-by picker can narrow to dimensions client-side — the only consumer that needs it.ChartContextMenunow filters oncolumn.groupby, which it already did on the extension path.Frontend.
SliceHeaderControlspassed!canDrillToDetailas theskipargument touseDatasetDrillInfo, which short-circuits to an empty dataset. "View as table" is offered to a different set of users (canExplore || canViewTable), so anyone in that set without Drill to detail — including the default Gamma role — never fetcheddrill_infoat all and still saw raw names, no matter what the API returned. The menu entry and the fetch that feeds its headers now share one predicate so they cannot drift, guarded bycan_get_drill_infoso a role without dataset read access does not fire a request that can only 403:createVerboseMapalso writes metrics before columns, so a column wins a name collision — uniqueness is only enforced within each list, and without this an unused metric could relabel a column the chart actually selected. This matchesSqlaTable.data_for_slices, which builds the verbose map the dashboard's own charts already render with.Behaviour changes worth noting
Payload.
drill_infonow returns every column rather than onlygroupby=Trueones, for all callers including embedded guests. Guests reach this endpoint only through the dashboard fallback, which first verifies dashboard access to a dashboard built on the dataset, and the response already carried dataset-level dimension names and analyst-authored labels; this widens that to non-dimension columns and metrics. The drill-by picker is unchanged from a user's perspective — the narrowing simply moved client-side.Cost. One additional
SELECTper request (measured: 12 → 13 during the request), the eager load ofsql_metrics. That query is unavoidable given the feature — without it inselect_columnsthe schema would lazy-load the same rows at dump time. Request counts are unchanged for default roles, sinceChartContextMenualready fetcheddrill_infoviacanDrillByand both call sites sharecachedSupersetGet's endpoint key.Extensions. Where
load.drillby.optionsis registered, the hook now also calls the REST endpoint for labels, because the extension contract only covers drill-by options and a conforming implementation may omit metrics and non-dimension columns. That is one extra request per dataset per dashboard load in those deployments only; if the endpoint is unreachable there, the verbose map falls back to the extension payload rather than failing drill-by.Video evidence
Before fix
before.webm
After fix
after.webm
TESTING INSTRUCTIONS
sum__num→ "Yearly Total", and a column with a Label that is not marked as a dimension (groupbyoff).can_view_chart_as_tableon Dashboard but not Drill to detail (e.g. default Gamma) and confirm the Labels resolve there too.pytest tests/integration_tests/datasets/api_tests.py -k drill_infopytest tests/unit_tests/datasets/schema_tests.py -k drill_infonpm run test -- SliceHeaderControls.test.tsx ChartContextMenu.test.tsx datasets.test.tsADDITIONAL INFORMATION