Skip to content

feat(mcp): add feature-gated interactive pivot support - #43480

Merged
rusackas merged 12 commits into
apache:masterfrom
aminghadersohi:aminghadersohi/mcp-interactive-pivot
Aug 30, 2026
Merged

rusackas merged 12 commits into
apache:masterfrom
aminghadersohi:aminghadersohi/mcp-interactive-pivot

Conversation

@aminghadersohi

@aminghadersohi aminghadersohi commented Aug 24, 2026 •

Copy link
Copy Markdown
Contributor

SUMMARY

Recreates and supersedes closed PR #43268 after its head repository was removed. This PR is explicitly based on apache/superset:master.

Adds a distinct, feature-gated MCP adapter for an extension-provided ag-grid-pivot-table visualization. This deliberately does not alias Interactive Pivot to the built-in pivot_table_v2 adapter.

The new interactive_pivot schema and plugin cover:

  • AG Grid row groups, pivot columns, metrics, metric aggregation, totals/subtotals, formats, filters, sorting, and cell/series limits
  • persisted pivot_table_state for the Rows, Column Labels, and Values side-panel buckets
  • period-over-period comparison through comparison_period plus comparison_type (values, difference, percentage, or ratio), mapped to the visualization's native time_compare array
  • schema discovery and examples, generated names, capabilities/semantics, and tabular chart-data handling
  • update/preview preservation of UI-managed AG Grid state while replacing declarative grouping and aggregation state
  • fail-closed availability through the host-defined AG_GRID_PIVOT_TABLE_ENABLED feature flag plus the existing MCP plugin filter, so deployments without the extension do not advertise an unavailable visualization

This implements SC-113786 while keeping the AG Grid visualization distinct from the built-in Pivot Table V2.

AG_GRID_PIVOT_TABLE_ENABLED is an extension availability contract rather than a new core rollout flag. Core deployments leave the adapter unavailable; deployments that ship the visualization define and enable the flag through their normal feature-flag configuration.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

Not applicable. This changes MCP schemas and form-data generation; it does not add or modify UI components.

TESTING INSTRUCTIONS

  1. On a host that registers the AG Grid Interactive Pivot extension, enable AG_GRID_PIVOT_TABLE_ENABLED.
  2. Call get_chart_type_schema("interactive_pivot") and verify the schema and examples are returned.
  3. Generate an Interactive Pivot with rows, columns, metrics, totals, comparison_period: "1 year ago", and comparison_type: "percentage".
  4. Verify the Explore URL uses viz_type=ag-grid-pivot-table, time_compare is ["1 year ago"], and the persisted grid state populates the AG Grid side-panel buckets.
  5. Update an existing Interactive Pivot and verify its concrete viz type, comparison controls, and UI-managed sizing/filter/sort state are retained.
  6. Disable the feature flag and verify schema discovery and generation return DISABLED_CHART_TYPE rather than offering a broken chart.

Automated validation run:

PYTHONPATH="$PWD/superset-core/src:$PWD" pytest -q tests/unit_tests/mcp_service/chart
# 1325 passed

PYTHONPATH="$PWD/superset-core/src:$PWD" pytest -q \
  tests/unit_tests/mcp_service/chart/test_interactive_pivot_chart.py \
  tests/unit_tests/mcp_service/chart/test_chart_utils.py \
  tests/unit_tests/mcp_service/chart/test_chart_config_coercion.py \
  tests/unit_tests/mcp_service/chart/tool/test_get_chart_type_schema.py \
  tests/unit_tests/mcp_service/chart/tool/test_update_chart_preview.py
# 267 passed

pre-commit run
# Passed

ADDITIONAL INFORMATION

  • Has associated issue: SC-113786
  • Required feature flags: host-defined AG_GRID_PIVOT_TABLE_ENABLED availability contract
  • 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

AI behavior / evaluation evidence

This is a deterministic schema, validation, and form-data mapping change. Unit tests cover schema examples, exact native viz resolution, feature-gated availability, comparison validation and round trips, side-panel state, update/preview preservation, capabilities, and generated naming. No model prompt, routing, retrieval, or sampling behavior changes.

Cost and latency

No additional model calls or network requests are introduced. Availability checks are in-process feature-flag lookups; chart mapping remains deterministic and local.

@dosubot dosubot Bot added change:backend Requires changing the backend viz:charts:pivot Related to the Pivot Table charts labels Aug 24, 2026
@bito-code-review

bito-code-review Bot commented Aug 24, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Agent Run #851990

Actionable Suggestions - 0
Additional Suggestions - 4
  • superset/mcp_service/chart/validation/schema_validator.py - 2
    • Missing translation function wrapper · Line 187-187
      Wrap the `message`, `details`, and each suggestion string in this error block with `t()` for i18n support, and add the corresponding `import` for the translation function.
    • Translation consistency for new suggestion · Line 134-135
      The new suggestion line 135 'Use 'interactive_pivot' only when schema discovery exposes it' added to the missing_chart_type error must also be wrapped with translation function per BITO.md rule [6516] to maintain consistency with translation requirements.
  • superset/mcp_service/chart/schemas.py - 1
    • Missing test for normalization mapping · Line 2235-2235
      The `_normalize_chart_request_input` function at line 2240 now handles `ag-grid-pivot-table` normalization, but lacks direct unit test coverage. Add a test case in `test_chart_utils.py` that validates the viz_type-to-chart_type mapping for this entry.
  • tests/unit_tests/mcp_service/chart/test_chart_utils.py - 1
    • Missing asymmetric viz_type test · Line 238-252
      Add test case for asymmetric viz_type mismatch — when existing is NOT ag-grid-pivot-table but updated is — to complete coverage of the guard condition.
Review Details
  • Files reviewed - 20 · Commit Range: 65e31ae..f41ad6d
    • docs/docs/using-superset/using-ai-with-superset.mdx
    • superset/mcp_service/app.py
    • superset/mcp_service/chart/chart_utils.py
    • superset/mcp_service/chart/plugin.py
    • superset/mcp_service/chart/plugins/__init__.py
    • superset/mcp_service/chart/plugins/interactive_pivot.py
    • superset/mcp_service/chart/registry.py
    • superset/mcp_service/chart/resources/chart_configs.py
    • superset/mcp_service/chart/schemas.py
    • superset/mcp_service/chart/tool/generate_chart.py
    • superset/mcp_service/chart/tool/get_chart_data.py
    • superset/mcp_service/chart/tool/get_chart_type_schema.py
    • superset/mcp_service/chart/tool/update_chart.py
    • superset/mcp_service/chart/tool/update_chart_preview.py
    • superset/mcp_service/chart/validation/schema_validator.py
    • tests/unit_tests/mcp_service/chart/test_chart_utils.py
    • tests/unit_tests/mcp_service/chart/test_interactive_pivot_chart.py
    • tests/unit_tests/mcp_service/chart/test_registry_filters.py
    • tests/unit_tests/mcp_service/chart/tool/test_get_chart_type_schema.py
    • tests/unit_tests/mcp_service/chart/tool/test_update_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 an incremental AI Review.

  • /review full - 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

@github-actions github-actions Bot added the doc Namespace | Anything related to documentation label Aug 24, 2026
@aminghadersohi

Copy link
Copy Markdown
Contributor Author

This recreates #43268 after its head repository was removed. The implementation and review fixes are unchanged, with the branch updated onto the latest apache/superset:master. Re-requesting review because GitHub could not reopen the original approved PR.

@netlify

netlify Bot commented Aug 24, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for superset-docs-preview ready!

Name Link
🔨 Latest commit ee9f3f0
🔍 Latest deploy log https://app.netlify.com/projects/superset-docs-preview/deploys/6a90ab21c9eb790008d17a83
😎 Deploy Preview https://deploy-preview-43480--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.

@bito-code-review

Copy link
Copy Markdown
Contributor

The flagged issue is correct. In superset/mcp_service/chart/plugins/interactive_pivot.py, the map_interactive_pivot_config function sets time_grain_sqla but fails to populate the temporal_columns_lookup control, which is required by the pivot table to identify which dimensions in the groupby list are temporal and should have the grain applied.

To resolve this, you should update map_interactive_pivot_config to populate temporal_columns_lookup with the names of the temporal columns present in the rows and columns lists. This ensures the pivot table correctly applies the time_grain_sqla to the intended dimensions.

Would you like me to implement this fix and check the rest of the PR comments for other issues?

superset/mcp_service/chart/plugins/interactive_pivot.py

if config.time_grain:
        form_data["time_grain_sqla"] = config.time_grain.value
        # Identify temporal dimensions for the pivot table
        temporal_cols = [col.name for col in config.rows + config.columns if col.is_temporal]
        form_data["temporal_columns_lookup"] = {col: True for col in temporal_cols}

@codecov

codecov Bot commented Aug 24, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 78.71287% with 43 lines in your changes missing coverage. Please review.
✅ Project coverage is 79.01%. Comparing base (c980b3a) to head (d62630a).
⚠️ Report is 146 commits behind head on master.

Files with missing lines Patch % Lines
...set/mcp_service/chart/plugins/interactive_pivot.py 68.75% 20 Missing and 10 partials ⚠️
superset/mcp_service/chart/registry.py 50.00% 4 Missing and 1 partial ⚠️
...erset/mcp_service/chart/resources/chart_configs.py 0.00% 4 Missing ⚠️
superset/mcp_service/chart/schemas.py 93.93% 2 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #43480      +/-   ##
==========================================
+ Coverage   78.92%   79.01%   +0.08%     
==========================================
  Files        2878     2880       +2     
  Lines      165105   165934     +829     
  Branches    38148    38323     +175     
==========================================
+ Hits       130314   131115     +801     
+ Misses      32341    32330      -11     
- Partials     2450     2489      +39     
Flag Coverage Δ
hive 37.91% <31.68%> (-0.11%) ⬇️
mysql 57.61% <31.68%> (-0.16%) ⬇️
postgres 57.64% <31.68%> (-0.16%) ⬇️
presto 39.82% <31.68%> (-0.13%) ⬇️
python 83.74% <78.71%> (+0.12%) ⬆️
sqlite 57.33% <31.68%> (-0.16%) ⬇️
unit 73.98% <78.71%> (+0.31%) ⬆️

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.

@gabotorresruiz gabotorresruiz 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.

Thanks for recreating this cleanly after the fork mishap, Amin. I verified the recreation rather than assuming it: I diffed all 20 changed files at f41ad6d against the content I approved on #43268 at 895af43, and the PR delta is line for line identical at both bases; the only differences are master drift the merge brought in. The approved history is preserved in the branch, the body carries the corrected time-comparison notes, tests/unit_tests/mcp_service/chart passes locally at this head (1,311 tests), and CI is green. Same content, same verdict. LGTM.

@bito-code-review

bito-code-review Bot commented Aug 25, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Agent Run #e6ddee

Actionable Suggestions - 0
Review Details
  • Files reviewed - 8 · Commit Range: f41ad6d..2e4e67f
    • docs/docs/using-superset/using-ai-with-superset.mdx
    • superset/mcp_service/app.py
    • superset/mcp_service/chart/plugins/interactive_pivot.py
    • superset/mcp_service/chart/resources/chart_configs.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_interactive_pivot_chart.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 an incremental AI Review.

  • /review full - 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

@bito-code-review

bito-code-review Bot commented Aug 27, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Agent Run #a0d8f3

Actionable Suggestions - 0
Review Details
  • Files reviewed - 7 · Commit Range: 2e4e67f..c60d5da
    • superset/mcp_service/chart/plugins/interactive_pivot.py
    • superset/mcp_service/chart/resources/chart_configs.py
    • superset/mcp_service/chart/schemas.py
    • superset/mcp_service/chart/tool/get_chart_type_schema.py
    • tests/unit_tests/mcp_service/chart/test_chart_config_coercion.py
    • tests/unit_tests/mcp_service/chart/test_chart_utils.py
    • tests/unit_tests/mcp_service/chart/test_interactive_pivot_chart.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 an incremental AI Review.

  • /review full - 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

@gabotorresruiz gabotorresruiz 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.

Re-verified the two commits since my last approval, Amin, and this still looks great. The de-vendoring keeps the flag contract intact (the constant rename does not change the AG_GRID_PIVOT_TABLE_ENABLED value, and I confirmed no stale references remain). The new grouping validation and the granularity_sqla plus temporal_columns_lookup emission match what the target plugin's buildQuery actually consults, so the time grain now applies to MCP generated charts without waiting for Explore hydration, which is strictly better than before. The chart suite passes locally at this head (1,315 tests) and CI is green. One small non-blocking nit inline. LGTM, again.

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

Code Review Agent Run #d9297b

Actionable Suggestions - 1
  • superset/mcp_service/chart/schemas.py - 1
Additional Suggestions - 1
  • superset/mcp_service/chart/schemas.py - 1
    • model_validator misses comparison_period alias · Line 1227-1239
      The `normalize_comparison_period` model_validator only inspects `data["time_compare"]`. Since the Field's `validation_alias` accepts both `comparison_period` and `time_compare`, a list passed as `comparison_period` bypasses the single-item check and reaches the field validator, which expects a `str | None`. Normalize both keys or restrict the alias.
Review Details
  • Files reviewed - 6 · Commit Range: c60d5da..ee9f3f0
    • superset/mcp_service/chart/plugins/interactive_pivot.py
    • tests/unit_tests/mcp_service/chart/test_interactive_pivot_chart.py
    • docs/docs/using-superset/using-ai-with-superset.mdx
    • superset/mcp_service/chart/resources/chart_configs.py
    • superset/mcp_service/chart/schemas.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 an incremental AI Review.

  • /review full - 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

Comment thread superset/mcp_service/chart/schemas.py Resolved
@bito-code-review

bito-code-review Bot commented Aug 28, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Agent Run #3f92d2

Actionable Suggestions - 0
Review Details
  • Files reviewed - 2 · Commit Range: ee9f3f0..d62630a
    • superset/mcp_service/chart/schemas.py
    • tests/unit_tests/mcp_service/chart/test_interactive_pivot_chart.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 an incremental AI Review.

  • /review full - 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

@rusackas
rusackas merged commit 2df06dc into apache:master Aug 30, 2026
75 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

change:backend Requires changing the backend doc Namespace | Anything related to documentation size/XXL viz:charts:pivot Related to the Pivot Table charts

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants