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

   ### SUMMARY
   
   Adds a `generate_chart` MCP plugin for the **heatmap** chart type 
(`viz_type: heatmap_v2`), so the MCP `generate_chart` tool can produce 
heatmaps. Heatmap is a shipped Superset viz type that had no MCP plugin; this 
closes that gap.
   
   The plugin mirrors the frontend Heatmap `buildQuery` contract: an `x_axis` 
column and a single `groupby` column form the two axes, one `metric` colours 
each cell, and `normalize_across` selects the server-side rank-normalization 
range (the whole `heatmap`, per-`x` column, or per-`y` row).
   
   Follows the established plugin pattern 
(`pie`/`funnel`/`gauge`/`treemap`/`waterfall`) — a config schema, a 
`map_*_config` mapper, a plugin class, and registration:
   
   - **`HeatmapChartConfig`** — `x_axis`, `y_axis`, and `metric` required; 
optional `normalize_across` (default `heatmap`), `row_limit`, `filters`. Added 
to the `ChartConfig` discriminated union and the `get_chart_type_schema` 
adapters. The Y axis accepts the native `groupby` alias and is emitted as a 
single-select `groupby` (not a list), matching the frontend control (`multi: 
false`). `x_axis`/`y_axis` may not be `saved_metric`/`sql_expression` 
(dimensions, not metrics).
   - **`map_heatmap_config`** — maps the config to `form_data`; saved metrics 
pass through as a bare name string, ad-hoc metrics as SIMPLE/SQL adhoc objects. 
The server applies the rank-normalization post-processing operator (driven by 
`normalize_across`).
   - **`HeatmapChartPlugin`** — registered in the plugin registry; `heatmap_v2` 
was already present in the recommendation category map.
   
   The field set is intentionally minimal (core query contract + 
normalization). Cosmetic controls (linear color scheme, legend/value display, 
sort axes, scale intervals) are left for a follow-up.
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   
   N/A — backend/MCP only, no UI change.
   
   ### TESTING INSTRUCTIONS
   
   `pytest tests/unit_tests/mcp_service/chart/test_heatmap_chart.py` — 18 unit 
tests cover schema validation (x/y/metric required, native `groupby` aliasing 
for the Y axis, `x_axis`/`y_axis`-not-a-metric, `normalize_across` enum, 
extra-field rejection), `ChartConfig` union dispatch, `form_data` mapping 
(viz_type/x_axis/groupby-as-single/metric/normalize/filters/saved-metric), and 
registry integration (registration, `resolve_viz_type`, `display_name`, 
`pre_validate`).
   
   To exercise end-to-end: call the `generate_chart` MCP tool with
   `{"chart_type": "heatmap_v2", "x_axis": {"name": "day_of_week"}, "y_axis": 
{"name": "hour"}, "metric": {"name": "trips", "aggregate": "COUNT"}}`.
   
   ### ADDITIONAL INFORMATION
   - [ ] Has associated issue:
   - [ ] Required feature flags:
   - [ ] Changes UI
   - [ ] Includes DB Migration (follow approval process in 
[SIP-59](https://github.com/apache/superset/issues/13351))
     - [ ] Migration is atomic, supports rollback & is backwards-compatible
     - [ ] Confirm DB migration upgrade and downgrade tested
     - [ ] Runtime estimates and downtime expectations provided
   - [x] Introduces new feature or API
   - [ ] Removes existing feature or API
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   


-- 
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