Skip to content

feat(mcp): histogram and box plot chart type plugins - #41860

Merged
rusackas merged 11 commits into
apache:masterfrom
gkneighb:feat/mcp-histogram-boxplot-plugins
Jul 15, 2026
Merged

rusackas merged 11 commits into
apache:masterfrom
gkneighb:feat/mcp-histogram-boxplot-plugins

Conversation

@gkneighb

@gkneighb gkneighb commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

SUMMARY

Adds histogram and box plot chart type plugins to the MCP generate_chart registry (#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:

  • Follows the plugin contract exactly: each type is a self-contained ChartTypePlugin under superset/mcp_service/chart/plugins/ (schema pre-validation with LLM-friendly fix suggestions, column-ref extraction/canonicalization, form_data mapping, name generation), registered in plugins/__init__.py. No registry or core changes.
  • form_data matches the frontend buildQuery contracts for viz_type="histogram_v2" (single column string, groupby names, bins/normalize/cumulative — bins default 5, same as the controlPanel) and viz_type="box_plot" (columns = distribute-across values, groupby = series dimensions, metrics, whiskerOptions). Box plot whiskers use an enum-style whisker_type (tukey / min_max / percentile with validated percentile_low < percentile_high) that serializes to the exact strings the frontend boxplotOperator parses, including its "<low>/<high> percentiles" regex format — an LLM never has to guess the magic strings.
  • Config schemas are strict (unknown fields rejected, SQL expressions rejected on dimension-position columns, saved_metric rejected on the histogram's binned column) with descriptive Pydantic errors, consistent with the existing chart configs.
  • histogram_v2 added 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_schema gains both types with examples; generate_chart docstring 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

pytest tests/unit_tests/mcp_service/chart/test_histogram_boxplot_charts.py  # 24 new tests
pytest tests/unit_tests/mcp_service/chart/                                  # full chart suite

Manual: via an MCP client, generate_chart with
{"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

  • Has associated issue:
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • Migration is atomic, supports rollback & is backwards-compatible
    • Confirm DB migration upgrade and downgrade tested
    • Runtime estimates and downtime expectations provided
  • Introduces new feature or API
  • Removes existing feature or API

🤖 Generated with Claude Code

https://claude.ai/code/session_014z1fQxTadTEvpCJLx9WnB8

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
@bito-code-review

bito-code-review Bot commented Jul 7, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Agent Run #9cff6d

Actionable Suggestions - 0
Additional Suggestions - 1
  • tests/unit_tests/mcp_service/chart/test_histogram_boxplot_charts.py - 1
    • Truthy assertion bypasses filter validation · Line 134-134
      Line 134 uses a Python truthy assertion (`assert x, msg`) instead of an equality assertion. This only checks that `adhoc_filters` is non-empty — it does NOT verify the filter was correctly mapped. If the filter is silently dropped or corrupted, the test still passes. Use explicit length + content assertions to validate the actual filter mapping.
Filtered by Review Rules

Bito filtered these suggestions based on rules created automatically for your feedback. Manage rules.

  • superset/mcp_service/chart/plugins/histogram.py - 1
Review Details
  • Files reviewed - 10 · Commit Range: 5332ec9..5332ec9
    • superset/mcp_service/app.py
    • superset/mcp_service/chart/chart_utils.py
    • superset/mcp_service/chart/plugins/__init__.py
    • superset/mcp_service/chart/plugins/box_plot.py
    • superset/mcp_service/chart/plugins/histogram.py
    • superset/mcp_service/chart/schemas.py
    • superset/mcp_service/chart/tool/generate_chart.py
    • superset/mcp_service/chart/tool/get_chart_type_schema.py
    • tests/unit_tests/mcp_service/chart/test_histogram_boxplot_charts.py
    • tests/unit_tests/mcp_service/chart/tool/test_get_chart_type_schema.py
  • Files skipped - 0
  • Tools
    • MyPy (Static Code Analysis) - ✔︎ Successful
    • Astral Ruff (Static Code Analysis) - ✔︎ Successful
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers a full AI review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at [email protected].

Documentation & Help

AI Code Review powered by Bito Logo

@dosubot dosubot Bot added viz:charts:boxplot Related to the Boxplot chart viz:charts:histogram Related to the Histogram chart labels Jul 7, 2026
@codecov

codecov Bot commented Jul 7, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 36.79245% with 134 lines in your changes missing coverage. Please review.
✅ Project coverage is 64.79%. Comparing base (5e6b29d) to head (1ec7363).
⚠️ Report is 52 commits behind head on master.

Files with missing lines Patch % Lines
superset/mcp_service/chart/plugins/histogram.py 31.81% 45 Missing ⚠️
superset/mcp_service/chart/plugins/box_plot.py 31.66% 41 Missing ⚠️
superset/mcp_service/chart/schemas.py 44.28% 39 Missing ⚠️
superset/mcp_service/chart/chart_utils.py 25.00% 9 Missing ⚠️
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     
Flag Coverage Δ
hive 39.04% <36.79%> (-0.03%) ⬇️
mysql 57.82% <36.79%> (-0.14%) ⬇️
postgres 57.88% <36.79%> (-0.15%) ⬇️
presto 41.02% <36.79%> (-0.04%) ⬇️
python 59.26% <36.79%> (-0.16%) ⬇️
sqlite 57.49% <36.79%> (-0.14%) ⬇️
unit 100.00% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Comment thread superset/mcp_service/chart/schemas.py Resolved
Comment thread superset/mcp_service/chart/schemas.py Resolved
Comment thread superset/mcp_service/chart/schemas.py Resolved
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
Comment thread superset/mcp_service/app.py Resolved
…/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
@bito-code-review

bito-code-review Bot commented Jul 12, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Agent Run #1970e2

Actionable Suggestions - 0
Review Details
  • Files reviewed - 4 · Commit Range: 5332ec9..a375284
    • superset/mcp_service/chart/schemas.py
    • tests/unit_tests/mcp_service/chart/test_histogram_boxplot_charts.py
    • superset/mcp_service/app.py
    • superset/mcp_service/chart/tool/get_chart_type_schema.py
  • Files skipped - 0
  • Tools
    • MyPy (Static Code Analysis) - ✔︎ Successful
    • Astral Ruff (Static Code Analysis) - ✔︎ Successful
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers a full AI review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at [email protected].

Documentation & Help

AI Code Review powered by Bito Logo

@aminghadersohi aminghadersohi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

netlify Bot commented Jul 14, 2026

Copy link
Copy Markdown

✅ Deploy Preview for superset-docs-preview ready!

Name Link
🔨 Latest commit 24eb424
🔍 Latest deploy log https://app.netlify.com/projects/superset-docs-preview/deploys/6a559108948fb000083af3b6
😎 Deploy Preview https://deploy-preview-41860--superset-docs-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

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
Comment thread superset/mcp_service/chart/schemas.py Resolved
Greg Neighbors and others added 2 commits July 13, 2026 22:24
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
Comment thread superset/mcp_service/chart/schemas.py Resolved
Comment thread superset/mcp_service/chart/schemas.py Resolved
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
@bito-code-review

bito-code-review Bot commented Jul 14, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Agent Run #7673f0

Actionable Suggestions - 0
Review Details
  • Files reviewed - 7 · Commit Range: a375284..532f3ce
    • superset/mcp_service/chart/plugins/histogram.py
    • tests/unit_tests/mcp_service/chart/test_histogram_boxplot_charts.py
    • superset/mcp_service/chart/plugins/box_plot.py
    • superset/mcp_service/chart/schemas.py
    • superset/mcp_service/app.py
    • superset/mcp_service/chart/tool/generate_chart.py
    • superset/mcp_service/chart/tool/get_chart_type_schema.py
  • Files skipped - 0
  • Tools
    • MyPy (Static Code Analysis) - ✔︎ Successful
    • Astral Ruff (Static Code Analysis) - ✔︎ Successful
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers a full AI review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at [email protected].

Documentation & Help

AI Code Review powered by Bito Logo

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
@bito-code-review

bito-code-review Bot commented Jul 14, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Agent Run #c96194

Actionable Suggestions - 0
Review Details
  • Files reviewed - 1 · Commit Range: 532f3ce..1ec7363
    • superset/mcp_service/chart/tool/get_chart_preview.py
  • Files skipped - 0
  • Tools
    • MyPy (Static Code Analysis) - ✔︎ Successful
    • Astral Ruff (Static Code Analysis) - ✔︎ Successful
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers a full AI review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at [email protected].

Documentation & Help

AI Code Review powered by Bito Logo

@gkneighb gkneighb mentioned this pull request Jul 15, 2026
1 of 9 tasks
@rusackas
rusackas merged commit 2bbb7d0 into apache:master Jul 15, 2026
59 checks passed
gkneighb pushed a commit to gkneighb/superset that referenced this pull request Jul 16, 2026
…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
rdg0 pushed a commit to rdg0/superset that referenced this pull request Jul 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/XXL viz:charts:boxplot Related to the Boxplot chart viz:charts:histogram Related to the Histogram chart

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants