You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "gkneighb (via GitHub)" <gi...@apache.org> on 2026/08/27 02:29:50 UTC
[PR] feat(mcp): treemap chart type plugin [superset]
gkneighb opened a new pull request, #43569:
URL: https://github.com/apache/superset/pull/43569
### SUMMARY
Adds a `generate_chart` MCP plugin for the **treemap** chart type (`viz_type: treemap_v2`), so the MCP `generate_chart` tool can produce treemaps. Treemap is a shipped Superset viz type that had no MCP plugin; this closes that gap.
The plugin mirrors the frontend Treemap `buildQuery` contract: one `metric` sizing the tiles plus an ordered `groupby` hierarchy — the first column is the outermost level and each subsequent column nests inside it. When `sort_by_metric` is set (the frontend default), tiles are ordered by the metric descending.
Follows the established plugin pattern (`pie`/`funnel`/`gauge`/`waterfall`) — a config schema, a `map_*_config` mapper, a plugin class, and registration:
- **`TreemapChartConfig`** — `metric` required and a non-empty ordered `groupby` list (the hierarchy); optional `sort_by_metric`, `row_limit`, `filters`, `color_scheme`. Added to the `ChartConfig` discriminated union and the `get_chart_type_schema` adapters. `groupby` entries may not be `saved_metric`/`sql_expression` (dimensions, not metrics).
- **`map_treemap_config`** — maps the config to `form_data`, preserving `groupby` order as the nesting hierarchy; saved metrics pass through as a bare name string, ad-hoc metrics as SIMPLE/SQL adhoc objects.
- **`TreemapChartPlugin`** — registered in the plugin registry; `treemap_v2` was already present in the recommendation category map.
The field set is intentionally minimal (core query contract). Cosmetic controls (label type, upper labels, number/date format) 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_treemap_chart.py` — 15 unit tests cover schema validation (required non-empty `groupby`, hierarchy order preserved, `groupby`-not-a-metric, extra-field rejection), `ChartConfig` union dispatch, `form_data` mapping (viz_type/groupby-order/metric/sort/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": "treemap_v2", "groupby": [{"name": "region"}, {"name": "product"}], "metric": {"name": "revenue", "aggregate": "SUM"}}`.
### 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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] feat(mcp): treemap chart type plugin [superset]
Posted by "aminghadersohi (via GitHub)" <gi...@apache.org>.
aminghadersohi merged PR #43569:
URL: https://github.com/apache/superset/pull/43569
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] feat(mcp): treemap chart type plugin [superset]
Posted by "netlify[bot] (via GitHub)" <gi...@apache.org>.
netlify[bot] commented on PR #43569:
URL: https://github.com/apache/superset/pull/43569#issuecomment-5457724961
### <span aria-hidden="true">✅</span> Deploy Preview for *superset-docs-preview* ready!
| Name | Link |
|:-:|------------------------|
|<span aria-hidden="true">🔨</span> Latest commit | 8f8ef8c16fae3893bb021c8b1e8feb3dc306a45a |
|<span aria-hidden="true">🔍</span> Latest deploy log | https://app.netlify.com/projects/superset-docs-preview/deploys/6a91f6a57fa1450008367492 |
|<span aria-hidden="true">😎</span> Deploy Preview | [https://deploy-preview-43569--superset-docs-preview.netlify.app](https://deploy-preview-43569--superset-docs-preview.netlify.app) |
|<span aria-hidden="true">📱</span> Preview on mobile | <details><summary> Toggle QR Code... </summary><br /><br /><br /><br />_Use your smartphone camera to open QR code link._</details> |
|<span aria-hidden="true">🤖</span> Make changes | [Run an agent on this branch](https://app.netlify.com/projects/superset-docs-preview/agent-runs#q1YqKMrPLShRslJS0lFKKkrMS84AstNSE0v0c5MLdEuKUlNzEwt0C3JK0zPzgEpSUgty8is9U4CKzBItDdPMEk3N0xINTUwNDAwsjM3MTSyNlGoB) |
---
<!-- [superset-docs-preview Preview](https://deploy-preview-43569--superset-docs-preview.netlify.app) -->
_To edit notification comments on pull requests, go to your [Netlify project configuration](https://app.netlify.com/projects/superset-docs-preview/configuration/notifications#deploy-notifications)._
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] feat(mcp): treemap chart type plugin [superset]
Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #43569:
URL: https://github.com/apache/superset/pull/43569#issuecomment-5614072137
AI Code Review is in progress (usually takes 3 to 15 minutes unless it's a very large PR).
<details>
<summary>
Bito Usage Guide
</summary>
**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 <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/available-commands" target="_blank" rel="noopener noreferrer">documentation</a> for additional commands.
**Configuration**
This repository uses `Superset` You can customize the agent settings <a href="https://alpha.bito.ai/home/ai-agents/code-review-agent" target="_blank" rel="noopener noreferrer">here</a> or contact your Bito workspace admin at evan@preset.io.
**Documentation & Help**
- <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/getting-started/install-run-using-bito-cloud/create-or-customize-an-agent-instance" target="_blank" rel="noopener noreferrer">Customize agent settings</a>
- <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/implementing-custom-code-review-rules" target="_blank" rel="noopener noreferrer">Review rules</a>
- <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent" target="_blank" rel="noopener noreferrer">General documentation</a>
- <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/faqs" target="_blank" rel="noopener noreferrer">FAQ</a>
</details>
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] feat(mcp): treemap chart type plugin [superset]
Posted by "codeant-ai-for-open-source[bot] (via GitHub)" <gi...@apache.org>.
codeant-ai-for-open-source[bot] commented on code in PR #43569:
URL: https://github.com/apache/superset/pull/43569#discussion_r3871255626
##########
superset/mcp_service/chart/schemas.py:
##########
@@ -1045,6 +1045,61 @@ def reject_sql_expression_on_dimensions(self) -> "PieChartConfig":
return self
+class TreemapChartConfig(BaseChartConfig):
+ """Config for treemap charts (viz_type ``treemap_v2``).
+
+ Matches the frontend Treemap buildQuery contract: one ``metric`` sizing
+ the tiles plus an ordered ``groupby`` hierarchy — the first column is the
+ outermost level and each subsequent column nests inside it. When
+ ``sort_by_metric`` is set, tiles are ordered by the metric descending.
+ """
+
+ model_config = ConfigDict(extra="ignore", populate_by_name=True)
+
+ chart_type: Literal["treemap_v2"] = "treemap_v2"
+ groupby: List[ColumnRef] = Field(
+ ...,
+ min_length=1,
+ description="Ordered category columns forming the treemap hierarchy "
+ "(first = outermost level; order defines nesting)",
+ )
+ metric: ColumnRef = Field(
+ ...,
+ description="Value metric sizing the tiles (use aggregate e.g. SUM, "
+ "COUNT for ad-hoc, or set saved_metric=True for a saved dataset metric)",
+ )
+ sort_by_metric: bool = Field(
+ True,
+ description="Order tiles by the metric descending (frontend default)",
+ )
+ row_limit: int = Field(100, description="Max rows queried", ge=1, le=10000)
+ filters: List[FilterConfig] | None = Field(
+ None,
+ description="Structured filters (column/op/value). "
+ "Do NOT use adhoc_filters or raw SQL expressions.",
+ )
+ color_scheme: str | None = Field(
+ None,
+ description=(
+ "Superset color scheme ID (e.g. 'supersetColors', 'lyftColors', "
+ "'googleCategory10c', 'd3Category10'). Defaults to 'supersetColors'."
+ ),
+ max_length=100,
+ )
+
+ @model_validator(mode="after")
+ def reject_metric_style_groupby(self) -> "TreemapChartConfig":
+ """groupby entries are hierarchy dimensions, not metrics."""
+ for i, col in enumerate(self.groupby or []):
+ _reject_sql_expression_on_dimension(col, f"groupby[{i}]")
+ if col.saved_metric:
+ raise ValueError(
+ f"groupby[{i}] cannot use saved_metric=True; "
+ "saved metrics belong in the 'metric' field"
+ )
+ return self
Review Comment:
**Suggestion:** The validator rejects `saved_metric` and `sql_expression`, but it still accepts `aggregate` on a `groupby` entry even though `aggregate` also marks a `ColumnRef` as a metric. `map_treemap_config` later emits only each entry's name, silently discarding the aggregate and changing an invalid metric-style hierarchy entry into an unaggregated dimension. Reject non-null `aggregate` values for treemap hierarchy columns as well. [api mismatch]
<details>
<summary><b>Severity Level:</b> Minor 🧹</summary>
```mdx
- ⚠️ `generate_chart` accepts invalid metric-style treemap hierarchy entries.
- ⚠️ Treemap form-data silently drops requested aggregates.
- ⚠️ Generated hierarchy differs from the caller’s configuration.
```
</details>
[](https://docs.codeant.ai/cli/resolve-pr-comments-skill) [](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=221fa095b50448aa9a326e094b04484a&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset) [](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=221fa095b50448aa9a326e094b04484a&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
<details>
<summary><b>Prompt for AI Agent 🤖 </b></summary>
```mdx
This is a comment left during a code review.
**Path:** superset/mcp_service/chart/schemas.py
**Line:** 1090:1100
**Comment:**
*Api Mismatch: The validator rejects `saved_metric` and `sql_expression`, but it still accepts `aggregate` on a `groupby` entry even though `aggregate` also marks a `ColumnRef` as a metric. `map_treemap_config` later emits only each entry's name, silently discarding the aggregate and changing an invalid metric-style hierarchy entry into an unaggregated dimension. Reject non-null `aggregate` values for treemap hierarchy columns as well.
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
```
</details>
<a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F43569&comment_hash=1149f400fdf1b757df82dd5b46363477f1abb7380314e5a56a4dc9c5c11b1a12&reaction=like'>👍</a> | <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F43569&comment_hash=1149f400fdf1b757df82dd5b46363477f1abb7380314e5a56a4dc9c5c11b1a12&reaction=dislike'>👎</a>
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] feat(mcp): treemap chart type plugin [superset]
Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #43569:
URL: https://github.com/apache/superset/pull/43569#issuecomment-5439972442
AI Code Review is in progress (usually takes 3 to 15 minutes unless it's a very large PR).
<details>
<summary>
Bito Usage Guide
</summary>
**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 <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/available-commands" target="_blank" rel="noopener noreferrer">documentation</a> for additional commands.
**Configuration**
This repository uses `Superset` You can customize the agent settings <a href="https://alpha.bito.ai/home/ai-agents/code-review-agent" target="_blank" rel="noopener noreferrer">here</a> or contact your Bito workspace admin at evan@preset.io.
**Documentation & Help**
- <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/getting-started/install-run-using-bito-cloud/create-or-customize-an-agent-instance" target="_blank" rel="noopener noreferrer">Customize agent settings</a>
- <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/implementing-custom-code-review-rules" target="_blank" rel="noopener noreferrer">Review rules</a>
- <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent" target="_blank" rel="noopener noreferrer">General documentation</a>
- <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/faqs" target="_blank" rel="noopener noreferrer">FAQ</a>
</details>
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] feat(mcp): treemap chart type plugin [superset]
Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #43569:
URL: https://github.com/apache/superset/pull/43569#issuecomment-5565593365
AI Code Review is in progress (usually takes 3 to 15 minutes unless it's a very large PR).
<details>
<summary>
Bito Usage Guide
</summary>
**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 <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/available-commands" target="_blank" rel="noopener noreferrer">documentation</a> for additional commands.
**Configuration**
This repository uses `Superset` You can customize the agent settings <a href="https://alpha.bito.ai/home/ai-agents/code-review-agent" target="_blank" rel="noopener noreferrer">here</a> or contact your Bito workspace admin at evan@preset.io.
**Documentation & Help**
- <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/getting-started/install-run-using-bito-cloud/create-or-customize-an-agent-instance" target="_blank" rel="noopener noreferrer">Customize agent settings</a>
- <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/implementing-custom-code-review-rules" target="_blank" rel="noopener noreferrer">Review rules</a>
- <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent" target="_blank" rel="noopener noreferrer">General documentation</a>
- <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/faqs" target="_blank" rel="noopener noreferrer">FAQ</a>
</details>
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] feat(mcp): treemap chart type plugin [superset]
Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #43569:
URL: https://github.com/apache/superset/pull/43569#issuecomment-5433602635
AI Code Review is in progress (usually takes 3 to 15 minutes unless it's a very large PR).
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] feat(mcp): treemap chart type plugin [superset]
Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #43569:
URL: https://github.com/apache/superset/pull/43569#issuecomment-5438298298
<!-- Bito Reply -->
The issue is valid. The `reject_metric_style_groupby` validator in `TreemapChartConfig` currently checks for `saved_metric` and `sql_expression` but fails to reject `aggregate` on `groupby` entries, which are intended to be dimensions. This allows invalid configurations that are later silently discarded.
To resolve this, update the `reject_metric_style_groupby` validator in `superset/mcp_service/chart/schemas.py` to also check for the presence of an `aggregate` value on `groupby` columns.
```python
@model_validator(mode="after")
def reject_metric_style_groupby(self) -> "TreemapChartConfig":
"""groupby entries are hierarchy dimensions, not metrics."""
for i, col in enumerate(self.groupby or []):
_reject_sql_expression_on_dimension(col, f"groupby[{i}]")
if col.saved_metric:
raise ValueError(
f"groupby[{i}] cannot use saved_metric=True; "
"saved metrics belong in the 'metric' field"
)
if col.aggregate:
raise ValueError(
f"groupby[{i}] cannot use aggregate='{col.aggregate}'; "
"aggregates belong in the 'metric' field"
)
return self
```
Would you like me to check the other comments on this PR and implement fixes for them as well?
**superset/mcp_service/chart/schemas.py**
```
if col.aggregate:
raise ValueError(
f"groupby[{i}] cannot use aggregate='{col.aggregate}'; "
"aggregates belong in the 'metric' field"
)
```
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] feat(mcp): treemap chart type plugin [superset]
Posted by "aminghadersohi (via GitHub)" <gi...@apache.org>.
aminghadersohi commented on PR #43569:
URL: https://github.com/apache/superset/pull/43569#issuecomment-5612400411
Re-reviewed `458631c26eb4515be0f6582f353523a409c16a90` against `8d0895e9`. Thanks for the refresh: **update-preview casing is fixed**, and both update paths preserve omitted `show_labels`/`number_format`. The remaining gaps from the previous review still reproduce:
- **Ordering:** with `row_limit=1`, the shared query builder emits only metric-descending order when enabled, and no `orderby` when disabled. Both cases still omit the frontend Treemap hierarchy ordering (`chart_helpers.py:578–585`).
- **Previews:** `region/product/SUM(revenue)` still renders through the saved/form-data-key scatter fallback (`get_chart_preview.py:575`) or an unsaved bar spec with only region color encoding, without a value axis or hierarchy (`preview_utils.py:953`).
- **Round-trip and update defaults:** native string hierarchy columns and saved/SIMPLE/SQL metric shapes still fail request validation. Both update paths reset omitted `color_scheme='lyftColors'`, `row_limit=7`, and `sort_by_metric=false` to `supersetColors`, `100`, and `true`. The Treemap schema/mapper still don't expose the frontend presentation controls; the shared merge's omitted-field handling is specialized for Gauge (`chart_utils.py:675–726`).
Validation: **1,578 chart tests passed, 1 skipped**, plus eight temporary diagnostic cases confirming the remaining gaps and the fixes above; Ruff and whitespace checks passed. The Treemap test file is unchanged and still lacks the requested product-path regression coverage. CI has no failing/pending checks and mergeability is clean, but those green checks don't cover these behaviors. Please address the remaining Treemap paths before considering support complete. No contributor-branch changes made.
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] feat(mcp): treemap chart type plugin [superset]
Posted by "codecov[bot] (via GitHub)" <gi...@apache.org>.
codecov[bot] commented on PR #43569:
URL: https://github.com/apache/superset/pull/43569#issuecomment-5433748934
## [Codecov](https://app.codecov.io/gh/apache/superset/pull/43569?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
:x: Patch coverage is `42.50000%` with `46 lines` in your changes missing coverage. Please review.
:white_check_mark: Project coverage is 66.33%. Comparing base ([`1c66b71`](https://app.codecov.io/gh/apache/superset/commit/1c66b71e232271011ec540a601288e5f99fcfa2f?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`63597b1`](https://app.codecov.io/gh/apache/superset/commit/63597b1098b2c71cdd3de9678f59b04f9f7a022a?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
| [Files with missing lines](https://app.codecov.io/gh/apache/superset/pull/43569?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Patch % | Lines |
|---|---|---|
| [superset/mcp\_service/chart/plugins/treemap.py](https://app.codecov.io/gh/apache/superset/pull/43569?src=pr&el=tree&filepath=superset%2Fmcp_service%2Fchart%2Fplugins%2Ftreemap.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3VwZXJzZXQvbWNwX3NlcnZpY2UvY2hhcnQvcGx1Z2lucy90cmVlbWFwLnB5) | 36.53% | [33 Missing :warning: ](https://app.codecov.io/gh/apache/superset/pull/43569?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
| [superset/mcp\_service/chart/chart\_utils.py](https://app.codecov.io/gh/apache/superset/pull/43569?src=pr&el=tree&filepath=superset%2Fmcp_service%2Fchart%2Fchart_utils.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3VwZXJzZXQvbWNwX3NlcnZpY2UvY2hhcnQvY2hhcnRfdXRpbHMucHk=) | 20.00% | [8 Missing :warning: ](https://app.codecov.io/gh/apache/superset/pull/43569?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
| [superset/mcp\_service/chart/schemas.py](https://app.codecov.io/gh/apache/superset/pull/43569?src=pr&el=tree&filepath=superset%2Fmcp_service%2Fchart%2Fschemas.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3VwZXJzZXQvbWNwX3NlcnZpY2UvY2hhcnQvc2NoZW1hcy5weQ==) | 68.75% | [5 Missing :warning: ](https://app.codecov.io/gh/apache/superset/pull/43569?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
> :exclamation: There is a different number of reports uploaded between BASE (1c66b71) and HEAD (63597b1). Click for more details.
>
> <details><summary>HEAD has 20 uploads less than BASE</summary>
>
>| Flag | BASE (1c66b71) | HEAD (63597b1) |
>|------|------|------|
>|hive|3|1|
>|python|17|3|
>|sqlite|3|1|
>|postgres|3|1|
></details>
<details><summary>Additional details and impacted files</summary>
```diff
@@ Coverage Diff @@
## master #43569 +/- ##
===========================================
- Coverage 79.10% 66.33% -12.77%
===========================================
Files 2878 2879 +1
Lines 165637 165717 +80
Branches 38295 38309 +14
===========================================
- Hits 131029 109931 -21098
- Misses 32122 53564 +21442
+ Partials 2486 2222 -264
```
| [Flag](https://app.codecov.io/gh/apache/superset/pull/43569/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
|---|---|---|
| [hive](https://app.codecov.io/gh/apache/superset/pull/43569/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `37.96% <42.50%> (+<0.01%)` | :arrow_up: |
| [mysql](https://app.codecov.io/gh/apache/superset/pull/43569/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
| [postgres](https://app.codecov.io/gh/apache/superset/pull/43569/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `57.72% <42.50%> (-0.02%)` | :arrow_down: |
| [presto](https://app.codecov.io/gh/apache/superset/pull/43569/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
| [python](https://app.codecov.io/gh/apache/superset/pull/43569/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `57.92% <42.50%> (-25.76%)` | :arrow_down: |
| [sqlite](https://app.codecov.io/gh/apache/superset/pull/43569/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `57.41% <42.50%> (-0.02%)` | :arrow_down: |
| [unit](https://app.codecov.io/gh/apache/superset/pull/43569/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#carryforward-flags-in-the-pull-request-comment) to find out more.
</details>
[:umbrella: View full report in Codecov by Harness](https://app.codecov.io/gh/apache/superset/pull/43569?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
<details><summary> :rocket: New features to boost your workflow: </summary>
- :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
- :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
</details>
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] feat(mcp): treemap chart type plugin [superset]
Posted by "aminghadersohi (via GitHub)" <gi...@apache.org>.
aminghadersohi commented on PR #43569:
URL: https://github.com/apache/superset/pull/43569#issuecomment-5574547463
Re-reviewed `8d0895e986ef786c7b901385e39928e5424b232b` against the previous head and refreshed base, also checking integration with master `53070fa4`. The range-diff is effectively a rebase; the previously requested Treemap gaps remain:
- **Ordering is partially fixed by the refreshed base:** `chart_helpers.py:508–517` emits metric-descending order, but omits the hierarchy tie-breakers. With `row_limit=1`, `sort_by_metric=false` still emits no `orderby`; the frontend Treemap `buildQuery` appends the ordered hierarchy in both cases.
- **Previews still aren't Treemaps:** for `region/product/SUM(revenue)` data, the saved/form-data-key strategy falls through to scatter (`get_chart_preview.py:488–531`); the unsaved helper emits a bar with only a region color encoding, no value axis or hierarchy (`preview_utils.py:470–566`). Please share a real Treemap spec across both paths.
- **Native round-trip/preservation remains missing:** request validation rejects native string `groupby` and saved/SIMPLE/SQL singular metric shapes. A replacement saved update drops omitted `show_labels`/`number_format` and resets `lyftColors` to `supersetColors` (`update_chart.py:233–252`); update-preview likewise resets omitted presentation values. The schema/mapper still lack the frontend presentation controls.
- **Update-preview casing:** lowercase hierarchy/metric names reach `validate_and_compile` unchanged against uppercase dataset columns (`update_chart_preview.py:220–274`), unlike generate/update normalization.
Validation: all **1,403 MCP chart tests pass**, as do Ruff on the six PR files and `git diff --check`; focused temporary reproductions expose the above behavior. The PR still adds only schema/mapper/registry Treemap tests, not the requested generate/update/update-preview/get-chart-data/preview workflow regressions. Please cover these behaviors before considering Treemap support complete. No contributor-branch changes made.
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] feat(mcp): treemap chart type plugin [superset]
Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #43569:
URL: https://github.com/apache/superset/pull/43569#issuecomment-5482585478
AI Code Review is in progress (usually takes 3 to 15 minutes unless it's a very large PR).
<details>
<summary>
Bito Usage Guide
</summary>
**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 <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/available-commands" target="_blank" rel="noopener noreferrer">documentation</a> for additional commands.
**Configuration**
This repository uses `Superset` You can customize the agent settings <a href="https://alpha.bito.ai/home/ai-agents/code-review-agent" target="_blank" rel="noopener noreferrer">here</a> or contact your Bito workspace admin at evan@preset.io.
**Documentation & Help**
- <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/getting-started/install-run-using-bito-cloud/create-or-customize-an-agent-instance" target="_blank" rel="noopener noreferrer">Customize agent settings</a>
- <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/implementing-custom-code-review-rules" target="_blank" rel="noopener noreferrer">Review rules</a>
- <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent" target="_blank" rel="noopener noreferrer">General documentation</a>
- <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/faqs" target="_blank" rel="noopener noreferrer">FAQ</a>
</details>
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] feat(mcp): treemap chart type plugin [superset]
Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #43569:
URL: https://github.com/apache/superset/pull/43569#issuecomment-5459004233
AI Code Review is in progress (usually takes 3 to 15 minutes unless it's a very large PR).
<details>
<summary>
Bito Usage Guide
</summary>
**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 <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/available-commands" target="_blank" rel="noopener noreferrer">documentation</a> for additional commands.
**Configuration**
This repository uses `Superset` You can customize the agent settings <a href="https://alpha.bito.ai/home/ai-agents/code-review-agent" target="_blank" rel="noopener noreferrer">here</a> or contact your Bito workspace admin at evan@preset.io.
**Documentation & Help**
- <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/getting-started/install-run-using-bito-cloud/create-or-customize-an-agent-instance" target="_blank" rel="noopener noreferrer">Customize agent settings</a>
- <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/implementing-custom-code-review-rules" target="_blank" rel="noopener noreferrer">Review rules</a>
- <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent" target="_blank" rel="noopener noreferrer">General documentation</a>
- <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/faqs" target="_blank" rel="noopener noreferrer">FAQ</a>
</details>
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] feat(mcp): treemap chart type plugin [superset]
Posted by "aminghadersohi (via GitHub)" <gi...@apache.org>.
aminghadersohi commented on PR #43569:
URL: https://github.com/apache/superset/pull/43569#issuecomment-5489130161
@gkneighb Thanks again for the solid typed Treemap foundation. I need to elevate my earlier non-blocking note after tracing the full customer-facing MCP paths: for Red Hat’s Treemap requirement, registration + mapping alone still leaves materially incorrect behavior, so could you please extend this PR before we count Treemap as complete?
1. **Server-side ordering:** mirror the frontend `buildQuery` contract—when a row limit applies, order by the singular metric descending when `sort_by_metric=true`, then by the ordered hierarchy columns. Today MCP emits no `orderby`, so a limit can return arbitrary leaves.
2. **Treemap previews:** add a real shared `treemap_v2` spec for both saved/form-data-key and unsaved previews, using every ordered hierarchy level plus the resolved singular metric label. Current saved preview falls through to scatter; unsaved falls through to an incomplete bar.
3. **Native round-trip + updates:** adapt native `groupby` strings and saved/SIMPLE/SQL singular metric shapes back into `TreemapChartConfig`; expose/map the frontend Treemap presentation controls and preserve omitted saved values (including color scheme) in both update tools.
4. **Product-path validation:** normalize update-preview column casing and add tests through generate/update/update-preview/get-chart-data/preview—not only direct model/mapper/registry tests.
At current head `86648530`, I ran the 16 Treemap tests, 435 focused shared tests, and the full MCP chart suite (1,383 passed); these gaps reproduce despite green CI. Shared query-error-envelope handling can coordinate with #43737 rather than be duplicated here, but the Treemap-specific behavior above needs coverage in this PR. I have not modified or pushed to your branch.
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] feat(mcp): treemap chart type plugin [superset]
Posted by "rebenitez1802 (via GitHub)" <gi...@apache.org>.
rebenitez1802 commented on code in PR #43569:
URL: https://github.com/apache/superset/pull/43569#discussion_r3895897040
##########
superset/mcp_service/chart/plugins/treemap.py:
##########
@@ -0,0 +1,144 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+"""Treemap chart type plugin."""
+
+from __future__ import annotations
+
+from collections.abc import Mapping
+from typing import Any, ClassVar
+
+from superset.mcp_service.chart.chart_utils import (
+ _summarize_filters,
+ _treemap_chart_what,
+ map_treemap_config,
+)
+from superset.mcp_service.chart.plugin import BaseChartPlugin
+from superset.mcp_service.chart.schemas import ColumnRef, TreemapChartConfig
+from superset.mcp_service.chart.validation.dataset_validator import DatasetValidator
+from superset.mcp_service.common.error_schemas import ChartGenerationError
+
+
+class TreemapChartPlugin(BaseChartPlugin):
+ """Plugin for treemap chart type."""
+
+ chart_type = "treemap_v2"
+ display_name = "Treemap"
+ native_viz_types: ClassVar[Mapping[str, str]] = {
+ "treemap_v2": "Treemap",
+ }
+
+ def pre_validate(
+ self,
+ config: dict[str, Any],
+ ) -> ChartGenerationError | None:
+ missing_fields = []
+
+ if not config.get("groupby"):
+ missing_fields.append("'groupby' (ordered hierarchy columns)")
+ if "metric" not in config:
+ missing_fields.append("'metric' (value metric sizing the tiles)")
+
+ if missing_fields:
+ return ChartGenerationError(
+ error_type="missing_treemap_fields",
+ message=(
+ f"Treemap chart missing required fields: "
+ f"{', '.join(missing_fields)}"
+ ),
+ details=(
+ "Treemaps size tiles by a metric and nest them by an "
+ "ordered groupby hierarchy (first column is the outermost "
+ "level)"
+ ),
+ suggestions=[
+ "Add 'groupby': [{'name': 'region'}, {'name': 'product'}]",
+ "Add 'metric': {'name': 'revenue', 'aggregate': 'SUM'}",
+ "Example: {'chart_type': 'treemap_v2', "
+ "'groupby': [{'name': 'region'}], "
+ "'metric': {'name': 'revenue', 'aggregate': 'SUM'}}",
+ ],
+ error_code="MISSING_TREEMAP_FIELDS",
+ )
+
+ return None
+
+ def extract_column_refs(self, config: Any) -> list[ColumnRef]:
+ if not isinstance(config, TreemapChartConfig):
+ return []
+ refs: list[ColumnRef] = [*config.groupby, config.metric]
+ if config.filters:
+ for f in config.filters:
+ refs.append(ColumnRef(name=f.column))
+ return refs
+
+ def to_form_data(
+ self, config: Any, dataset_id: int | str | None = None
+ ) -> dict[str, Any]:
+ return map_treemap_config(config)
+
+ def generate_name(self, config: Any, dataset_name: str | None = None) -> str:
+ what = _treemap_chart_what(config)
+ context = _summarize_filters(config.filters)
+ return self._with_context(what, context)
+
+ def resolve_viz_type(self, config: Any) -> str:
+ return "treemap_v2"
+
+ def normalize_column_refs(self, config: Any, dataset_context: Any) -> Any:
Review Comment:
**`normalize_column_refs` has no test coverage.**
This is the most branch-heavy method in the plugin — per-column canonicalization of `groupby`, plus the three-way metric branch (`sql_expression` → passthrough, `saved_metric` → `get_canonical_metric_name`, else → `get_canonical_column_name`) — and it's dispatched in the live validation flow (`superset/mcp_service/chart/validation/dataset_validator.py:537`), yet nothing in `test_treemap_chart.py` exercises it.
The repo already guards exactly this saved-metric column-vs-metric casing branch for every other metric-bearing chart type via `TestSavedMetricNormalizationCorrectness` in `tests/unit_tests/mcp_service/chart/test_column_name_normalization.py` (xy / table / pie / big_number / mixed). Treemap is the only metric-bearing type missing, so a casing regression here would fail silently.
Suggested: add a treemap case to that class asserting (a) a plain `groupby` column is canonicalized, (b) a `saved_metric` metric routes through `get_canonical_metric_name`, (c) an adhoc-column metric routes through `get_canonical_column_name`, and (d) a `sql_expression` metric is left untouched.
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org