mikebridge opened a new pull request, #44269:
URL: https://github.com/apache/superset/pull/44269
### SUMMARY
`get_dashboard_datasets` groups a dashboard's charts by datasource, but
resolved each group through `Slice.datasource`, which is deliberately
`SqlaTable`-only (access checks and exports depend on that type). A chart
targeting a semantic view therefore contributed nothing, and a dashboard whose
charts all target a semantic view answered `dataset_count: 0, datasets: []` —
the agent has no way to learn what columns or metrics that dashboard actually
uses.
Each group is now resolved by its `datasource_type`: semantic-view charts go
through the type-guarded `Slice.semantic_view` relationship (so a same-id table
can never be mistaken for a view — the grouping key already includes the type),
tables keep `Slice.datasource`. Both kinds are `Explorable`s exposing `columns`
/ `metrics`, so the existing serialization is shared. Access is checked per
kind: `has_dataset_access` for tables, the view's own `raise_for_access` (view
perm or semantic-layer perm) for views, failing closed on any unexpected error
— `security_manager.can_access_datasource` expects a `BaseDatasource` and
cannot be used for a view. The view relationship is eager-loaded alongside the
existing table chain.
Response additions on each entry (existing fields and their values
unchanged):
| field | table | semantic view |
|---|---|---|
| `datasource_type` | `"table"` (default) | `"semantic_view"` |
| `name` | table name | view name |
| `semantic_layer` | `null` | `{uuid, name}` (a semantic layer is keyed by
UUID; it has no integer id) |
| `table_name` / `schema` / `database` | unchanged | `null` |
### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
Live `superset mcp run`, dashboard holding one table chart and one
semantic-view chart:
```
before: dataset_count: 0 datasets: []
after: dataset_count: 2 inaccessible: 0
- semantic_view id=1 name="Jaffle Shop" table_name=None database=None
semantic_layer={uuid: 428c92c2…, name: "dbt Semantic Layer (MetricFlow)"}
columns=27 (9 temporal) metrics=23 chart_count=1
- table id=2 name="dashboards" table_name="dashboards"
database="sc120961_control"
semantic_layer=None columns=19 (3 temporal) metrics=1 chart_count=1
```
### TESTING INSTRUCTIONS
```
pytest tests/unit_tests/mcp_service/dashboard/
```
New tests cover the mixed dashboard, a table and a view sharing id 1 on one
dashboard (two entries, not one), an inaccessible view (excluded and counted in
`inaccessible_dataset_count` while the table on the same dashboard is still
returned), and the view-only dashboard — that last one was verified red-first
(`assert 0 == 1` before the change).
### ADDITIONAL INFORMATION
- [x] Has associated issue: sc-120961
- [ ] 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
- [ ] Introduces new feature or API
- [ ] Removes existing feature or API
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01267VBWbvWTNZUg9GvXKgkC
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]