geido opened a new pull request, #43522:
URL: https://github.com/apache/superset/pull/43522

   ### SUMMARY
   On a dashboard, opening a chart's context menu → "View as table" (the Chart 
Data modal, `ResultsPaneOnDashboard`) showed a metric's raw technical name 
(e.g. `sum__num`) as the results-grid column header instead of its friendly 
Label (verbose_name), even though the chart itself rendered the Label correctly 
and even for a full-permission Admin user.
   
   Root cause: the results-grid header comes from `columnDisplayNames?.[key] ?? 
key` in `useGridResultTable`, fed by `datasetWithVerboseMap?.verbose_map` in 
`SliceHeaderControls`, which is built by the `useDatasetDrillInfo` hook 
(`superset-frontend/src/hooks/apiResources/datasets.ts`). That hook's 
`createVerboseMap()` already correctly merges both `dataset.columns` and 
`dataset.metrics` into the map — so the frontend logic was not the problem.
   
   The actual bug is on the backend: `GET /api/v1/dataset/<pk>/drill_info/` 
(`superset/datasets/api.py`) only ever selected 
`columns.column_name`/`columns.verbose_name` and `DatasetDrillInfoSchema` 
(`superset/datasets/schemas.py`) had no `metrics` field at all. This endpoint 
was purpose-built for the Drill-to-Detail "drill by" dimension picker, which is 
inherently columns-only, but it was reused to source `verbose_map` for the 
results grid. Since the API response never included a `metrics` key, 
`dataset?.metrics` was always `undefined` on the frontend, so metric verbose 
names were silently dropped — independent of the viewer's Drill-to-Detail 
permission.
   
   Fix: add `metrics.metric_name`/`metrics.verbose_name` to the drill_info 
select columns and add a `metrics` field (via a new 
`DatasetMetricDrillInfoSchema`) to `DatasetDrillInfoSchema`, passed through 
unfiltered (unlike columns, which stay dimension-only for drill-by purposes) 
and included in the guest-user response branch as well, since metric labels 
aren't sensitive.
   
   No frontend changes were needed — `createVerboseMap`/`useDatasetDrillInfo` 
already handle metrics correctly once the API sends them.
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   N/A (backend API fix; see Shortcut ticket SC-115797 for repro screenshots)
   
   ### TESTING INSTRUCTIONS
   - Create a dataset with a metric that has a Label (verbose_name) set, e.g. 
`sum__num` → "Yearly Total".
   - Build a chart from it and add it to a dashboard.
   - Confirm the chart itself shows "Yearly Total".
   - Open the chart's context menu → "View as table" and confirm the 
results-grid column header now shows "Yearly Total" instead of `sum__num`.
   - `pytest tests/integration_tests/datasets/api_tests.py -k drill_info`
   
   ### ADDITIONAL INFORMATION
   - [x] Has associated issue: SC-115797
   - [ ] Required feature flags:
   - [ ] Changes UI
   - [ ] Includes DB Migration
   - [ ] Introduces new feature or API
   - [ ] Removes existing feature or API


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to