Skip to content

fix(mcp): expose table column formatting - #42658

Open
aminghadersohi wants to merge 4 commits into
apache:masterfrom
aminghadersohi:aminghadersohi/table-column-formatting
Open

fix(mcp): expose table column formatting#42658
aminghadersohi wants to merge 4 commits into
apache:masterfrom
aminghadersohi:aminghadersohi/table-column-formatting

Conversation

@aminghadersohi

Copy link
Copy Markdown
Contributor

SUMMARY

Expose per-column table formatting in MCP chart configurations. Table configs can set columnWidth, d3NumberFormat, and d3TimeFormat, keyed by result column label, and the generated schema documents concrete D3 format examples.

Existing table column_config values are preserved when an update omits the field, while explicit values are validated and serialized without silently dropping unknown settings.

TESTING INSTRUCTIONS

pytest -q tests/unit_tests/mcp_service/chart/test_new_chart_types.py tests/unit_tests/mcp_service/chart/tool/test_get_chart_type_schema.py tests/unit_tests/mcp_service/chart/tool/test_update_chart.py tests/unit_tests/mcp_service/chart/tool/test_update_chart_preview.py
uvx pre-commit run --files superset/mcp_service/chart/chart_utils.py superset/mcp_service/chart/schemas.py superset/mcp_service/chart/tool/update_chart.py superset/mcp_service/chart/tool/update_chart_preview.py tests/unit_tests/mcp_service/chart/test_new_chart_types.py tests/unit_tests/mcp_service/chart/tool/test_get_chart_type_schema.py tests/unit_tests/mcp_service/chart/tool/test_update_chart.py tests/unit_tests/mcp_service/chart/tool/test_update_chart_preview.py

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags:
  • Changes UI
  • Includes DB Migration
  • Introduces new feature or API
  • Removes existing feature or API

BLAST RADIUS

Limited to MCP table chart configuration schemas and form-data mapping. It does not change authorization, database models, migrations, or non-MCP chart behavior.

RISK AND ROLLBACK

The main risk is accepting a formatting value that the frontend renders differently than expected. Validation constrains field names and primitive types, and rollback is a normal revert with no data migration.

REVIEW GUIDANCE

Start with TableColumnConfig in schemas.py, then review the form-data mapping and preservation paths in the two update tools.

EVAL EVIDENCE

The deterministic schema and round-trip paths are covered by 189 passing focused MCP unit tests. No model-based evaluation suite was available in this checkout.

COST AND LATENCY DELTA

No prompt, model, routing, or tool-call changes. The added local schema validation and dictionary serialization have negligible request cost and latency impact.

PROMPT / NON-DETERMINISM

No prompt or non-deterministic behavior changed.

@codecov

codecov Bot commented Jul 31, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 20.93023% with 34 lines in your changes missing coverage. Please review.
✅ Project coverage is 65.71%. Comparing base (4278f4b) to head (2b8d9de).

Files with missing lines Patch % Lines
superset/mcp_service/chart/chart_utils.py 9.52% 19 Missing ⚠️
superset/mcp_service/chart/tool/update_chart.py 7.14% 13 Missing ⚠️
...set/mcp_service/chart/tool/update_chart_preview.py 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #42658      +/-   ##
==========================================
- Coverage   65.73%   65.71%   -0.02%     
==========================================
  Files        2843     2843              
  Lines      162653   162681      +28     
  Branches    37239    37242       +3     
==========================================
- Hits       106916   106913       -3     
- Misses      53644    53675      +31     
  Partials     2093     2093              
Flag Coverage Δ
hive 37.95% <20.93%> (-0.01%) ⬇️
mysql 57.77% <20.93%> (-0.02%) ⬇️
postgres 57.82% <20.93%> (-0.02%) ⬇️
presto 39.86% <20.93%> (-0.01%) ⬇️
python 59.18% <20.93%> (-0.02%) ⬇️
sqlite 57.45% <20.93%> (-0.02%) ⬇️
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.

@netlify

netlify Bot commented Aug 4, 2026

Copy link
Copy Markdown

Deploy Preview for superset-docs-preview ready!

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

@aminghadersohi
aminghadersohi marked this pull request as ready for review August 4, 2026 23:41
@dosubot dosubot Bot added the viz:charts:table Related to the Table chart label Aug 4, 2026
@bito-code-review

bito-code-review Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Code Review Agent Run #770bbd

Actionable Suggestions - 0
Review Details
  • Files reviewed - 9 · Commit Range: 8d95b8f..f886cc9
    • superset/mcp_service/chart/chart_utils.py
    • superset/mcp_service/chart/schemas.py
    • superset/mcp_service/chart/tool/update_chart.py
    • superset/mcp_service/chart/tool/update_chart_preview.py
    • tests/unit_tests/mcp_service/chart/test_chart_utils.py
    • tests/unit_tests/mcp_service/chart/test_new_chart_types.py
    • tests/unit_tests/mcp_service/chart/tool/test_get_chart_type_schema.py
    • tests/unit_tests/mcp_service/chart/tool/test_update_chart.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 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 evan@preset.io.

Documentation & Help

AI Code Review powered by Bito Logo

Comment on lines +574 to +578
if config.column_config is not None:
form_data["column_config"] = {
label: column.model_dump(by_alias=True, exclude_none=True)
for label, column in config.column_config.items()
}

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.

Suggestion: TableColumnConfig permits nullable formatting fields, but exclude_none=True removes an explicitly supplied null before merging. Consequently, a request that sets columnWidth, d3NumberFormat, or d3TimeFormat to null is indistinguishable from omission and the existing UI value is preserved instead of cleared. Preserve explicit nulls or provide a separate clear operation/serialization path. [state lifecycle]

Severity Level: Major ⚠️
- ⚠️ MCP users cannot clear existing column formatting.
- ⚠️ Table previews retain obsolete D3 formatting settings.

Fix in Cursor Fix in VSCode Claude

(Use Cmd/Ctrl + Click for best experience)

Prompt for AI Agent 🤖
This is a comment left during a code review.

**Path:** superset/mcp_service/chart/chart_utils.py
**Line:** 574:578
**Comment:**
	*State Lifecycle: `TableColumnConfig` permits nullable formatting fields, but `exclude_none=True` removes an explicitly supplied `null` before merging. Consequently, a request that sets `columnWidth`, `d3NumberFormat`, or `d3TimeFormat` to `null` is indistinguishable from omission and the existing UI value is preserved instead of cleared. Preserve explicit nulls or provide a separate clear operation/serialization path.

Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix
👍 | 👎

parsed_config, dataset_id=effective_dataset_id
)
new_form_data.pop("_mcp_warnings", None)
merge_table_column_config(_get_existing_form_data(chart), new_form_data)

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.

Suggestion: The table-column merge runs for every chart configuration, even when parsed_config is an XY, pie, or other non-table chart. Updating a table into another visualization therefore persists the old table column_config in the new chart parameters, allowing stale table formatting to reappear if the chart later returns to a table. Restrict this merge to table configurations or remove table-only state when changing visualization type. [api mismatch]

Severity Level: Major ⚠️
- ⚠️ Visualization changes retain stale table formatting state.
- ⚠️ Returning to tables can apply obsolete column settings.

Fix in Cursor Fix in VSCode Claude

(Use Cmd/Ctrl + Click for best experience)

Prompt for AI Agent 🤖
This is a comment left during a code review.

**Path:** superset/mcp_service/chart/tool/update_chart.py
**Line:** 135:135
**Comment:**
	*Api Mismatch: The table-column merge runs for every chart configuration, even when `parsed_config` is an XY, pie, or other non-table chart. Updating a table into another visualization therefore persists the old table `column_config` in the new chart parameters, allowing stale table formatting to reappear if the chart later returns to a table. Restrict this merge to table configurations or remove table-only state when changing visualization type.

Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix
👍 | 👎

Comment on lines +190 to +191
if previous_form_data:
merge_table_column_config(previous_form_data, new_form_data)

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.

Suggestion: The preview path imports column_config from arbitrary cached form data without checking the cached chart type or whether the new configuration is a table. Reusing a preview key while switching to an XY or another visualization therefore carries table-only formatting and stale column settings into the new preview. Apply this preservation only when both the cached and requested configurations are table charts, and clear it on chart-type transitions. [stale reference]

Severity Level: Major ⚠️
- ⚠️ Preview iterations retain table-only configuration state.
- ⚠️ Switching visualization types can restore obsolete formatting.

Fix in Cursor Fix in VSCode Claude

(Use Cmd/Ctrl + Click for best experience)

Prompt for AI Agent 🤖
This is a comment left during a code review.

**Path:** superset/mcp_service/chart/tool/update_chart_preview.py
**Line:** 190:191
**Comment:**
	*Stale Reference: The preview path imports `column_config` from arbitrary cached form data without checking the cached chart type or whether the new configuration is a table. Reusing a preview key while switching to an XY or another visualization therefore carries table-only formatting and stale column settings into the new preview. Apply this preservation only when both the cached and requested configurations are table charts, and clear it on chart-type transitions.

Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix
👍 | 👎

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/L viz:charts:table Related to the Table chart

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants