Repository navigation
feat(mcp): histogram and box plot chart type plugins - #41860
Conversation
Add the first statistical chart types to the generate_chart plugin registry: chart_type="histogram" (viz_type histogram_v2; binned column, bins/normalize/cumulative, optional groupby series) and chart_type="box_plot" (metrics + distribute_across + optional dimensions; whisker_type enum serializing to the exact whiskerOptions strings the frontend boxplotOperator parses, including the "<low>/<high> percentiles" regex format). form_data mapping matches the frontend buildQuery contracts; histogram_v2 added to the viz_type alias map; get_chart_type_schema, generate_chart docstring, and server instructions updated. 24 unit tests. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_014z1fQxTadTEvpCJLx9WnB8
Code Review Agent Run #9cff6dActionable Suggestions - 0Additional Suggestions - 1
Filtered by Review RulesBito filtered these suggestions based on rules created automatically for your feedback. Manage rules.
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 |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #41860 +/- ##
==========================================
- Coverage 64.88% 64.79% -0.09%
==========================================
Files 2742 2748 +6
Lines 153378 153848 +470
Branches 35168 35237 +69
==========================================
+ Hits 99516 99685 +169
- Misses 51958 52253 +295
- Partials 1904 1910 +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:
|
groupby (histogram) and distribute_across/dimensions (box plot) blocked sql_expression but still accepted saved_metric=True, which would emit a metric name where the query expects a physical column (review: codeant). Three tests. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_014z1fQxTadTEvpCJLx9WnB8
…/box_plot Two passages still declared 7 supported types (server instructions chart_type_display_name note; get_chart_type_schema docstring) — contradicting the updated discriminator docs (review: codeant). Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_014z1fQxTadTEvpCJLx9WnB8
Code Review Agent Run #1970e2Actionable 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 |
aminghadersohi
left a comment
There was a problem hiding this comment.
Deep-dove on plugin correctness by cross-checking against the actual frontend histogram_v2/box_plot viz plugin source (buildQuery, histogramOperator, boxplotOperator) rather than assuming — form_data mapping matches exactly, including the tricky whisker-type string/regex serialization. Input validation is solid (bins 1–1000, percentile ordering, saved_metric bypass on dimension fields already fixed per the codeant threads below). Schema examples in get_chart_type_schema.py validate cleanly against the actual Pydantic constraints, and the stale "7 chart types" docs are fixed at HEAD. Tests are meaningful (boundary + exact frontend-string assertions), not vacuous. One new finding inline below. codeant-ai's type-annotation nits are already declined with a reasonable standing rationale (matches existing plugin convention, mypy passes) — not re-raised; the saved_metric/stale-docs threads are confirmed fixed at HEAD — not re-raised.
post_map_validate now mirrors the Explore UI's numeric-only column restriction: a non-numeric column returns a structured error naming the dataset's numeric columns (and pointing category-frequency intents at xy/bar) instead of failing at query time (review: aminghadersohi). Three tests. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_014z1fQxTadTEvpCJLx9WnB8
✅ Deploy Preview for superset-docs-preview ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
- Numeric fallback now stem-matches backend type spellings (BIGINT, SMALLINT, REAL, NUMBER, DOUBLE PRECISION) instead of an exact-name list that rejected valid numeric columns (review: codeant) - Box-plot suggestions no longer claim every metric needs aggregate; saved_metric=True is equally valid (review: codeant) - Type the test helper return as ChartGenerationError | None (CI mypy) Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_014z1fQxTadTEvpCJLx9WnB8
Substring stem matching treated INTERVAL and POINT as numeric because they contain "INT"; match numeric tokens at word boundaries instead (review: codeant). Tests cover INTERVAL/POINT rejection and BIGINT/SMALLINT/DOUBLE PRECISION/REAL acceptance. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_014z1fQxTadTEvpCJLx9WnB8
…ontrol The frontend box plot uses the shared row-limit default of 10000; the config's 100 default would silently truncate grouped rows (review: codeant). Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_014z1fQxTadTEvpCJLx9WnB8
The schema documented distribute_across as the box-splitting axis, but the boxplot post-processor groups by form_data 'groupby' (the 'dimensions' field) — a minimal config produced a single collapsed box (review: codeant, Critical). Descriptions, examples, docstrings, name generation, and server instructions now state the true contract: distribute_across = sample axis (form_data 'columns'), dimensions = one box per value (form_data 'groupby'). Also accept Superset-native payload keys per the translate-don't-refuse convention: 'columns'/'groupby' aliases and whiskerOptions display strings (Tukey / Min-max / "<low>/<high> percentiles"). Four tests. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_014z1fQxTadTEvpCJLx9WnB8
pre_validate now accepts the 'columns' alias for distribute_across, and the whiskerOptions pre-normalizer always consumes the alias (explicit whisker_type wins) so sending both keys no longer trips the unknown-field check (review: codeant). Two tests. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_014z1fQxTadTEvpCJLx9WnB8
Code Review Agent Run #7673f0Actionable 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 |
The preview path mapped only the legacy histogram viz name, so charts created by the histogram plugin (viz_type histogram_v2) were misclassified — same dual-spelling treatment heatmap already gets (review: codeant). Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_014z1fQxTadTEvpCJLx9WnB8
Code Review Agent Run #c96194Actionable 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 |
…c fixes - Add time_grain (alias time_grain_sqla) so a temporal x_axis is bucketed rather than sent as raw timestamps, matching the frontend Waterfall control panel and the xy/mixed/big_number pattern (review: codeant) - Accept the native form_data shape where groupby is a one-item list (frontend Breakdowns is single-select but stores a list); reject multi-item lists rather than silently dropping (review: codeant) - Fix merge artifacts from the apache#41860 rebase: the get_chart_type_schema docstring listed two contradictory type sets; the dataset_validator docstring overstated coverage - Replace the brittle chart-type-count assertion with adapter-registry parity (review: codeant) Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_014z1fQxTadTEvpCJLx9WnB8
Co-authored-by: Greg Neighbors <[email protected]> Co-authored-by: Claude Fable 5 <[email protected]>
SUMMARY
Adds histogram and box plot chart type plugins to the MCP
generate_chartregistry (#39922), extending the creatable chart types from 7 families to 9. These are the first statistical charts the MCP service can generate — agents doing exploratory analysis previously had no way to look at a value distribution or compare spreads.Design notes:
ChartTypePluginundersuperset/mcp_service/chart/plugins/(schema pre-validation with LLM-friendly fix suggestions, column-ref extraction/canonicalization, form_data mapping, name generation), registered inplugins/__init__.py. No registry or core changes.viz_type="histogram_v2"(singlecolumnstring,groupbynames,bins/normalize/cumulative— bins default 5, same as the controlPanel) andviz_type="box_plot"(columns= distribute-across values,groupby= series dimensions,metrics,whiskerOptions). Box plot whiskers use an enum-stylewhisker_type(tukey/min_max/percentilewith validatedpercentile_low < percentile_high) that serializes to the exact strings the frontendboxplotOperatorparses, including its"<low>/<high> percentiles"regex format — an LLM never has to guess the magic strings.histogram_v2added to the viz_type→chart_type alias map so clients that send Superset's public viz name instead of the discriminator get translated rather than rejected;get_chart_type_schemagains both types with examples;generate_chartdocstring and server instructions updated.Part of a series extending MCP chart-type coverage (registry groundwork: #39922).
BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
N/A (MCP service; no UI changes)
TESTING INSTRUCTIONS
Manual: via an MCP client,
generate_chartwith{"dataset_id": <id>, "config": {"chart_type": "histogram", "column": {"name": "<numeric_col>"}, "bins": 20}}returns a working preview; same for
{"chart_type": "box_plot", "metrics": [{"name": "<col>", "aggregate": "AVG"}], "distribute_across": [{"name": "<category_col>"}]}.ADDITIONAL INFORMATION
🤖 Generated with Claude Code
https://claude.ai/code/session_014z1fQxTadTEvpCJLx9WnB8