mikebridge opened a new pull request, #44393:
URL: https://github.com/apache/superset/pull/44393

   ### SUMMARY
   
   Allow MCP chart tools to target semantic views explicitly with `view_id`, 
rather than resolving a view's numeric ID as an unrelated table dataset. 
Addresses [SC-120959](https://app.shortcut.com/preset/story/120959).
   
   - `generate_chart` / `generate_explore_link`: exactly one `dataset_id` or 
`view_id`; `update_chart`: at most one replacement selector. View IDs accept 
UUIDs or positive legacy numeric IDs.
   - Resolve views through the semantic registry and authorize before reading 
metadata. Preserve source family through query compilation, preview, 
permalink/cache and chart-command payloads.
   - Use saved semantic metrics/dimensions; reject explicit or implicit ad-hoc 
aggregation, retained custom SQL and invalid sort references. Validate retained 
state on rebind and compile semantic updates before caching/writing.
   - Preserve table behavior and existing table test cases. No migrations, new 
endpoints, provider changes, shell changes or deployment pins.
   
   **Dependency / merge gate:** semantic chart save/access requires Kunal's 
#44169 (`f45377454a55a3f65aebb9e4b32f53361c2d7b6f` when checked). This PR does 
not copy its changes or bypass the existing chart-command guards. Standalone 
master still rejects semantic chart persistence. Mocked save tests prove 
payload routing and no-write failure behavior, not durable semantic save. Keep 
this dependency and its integration check as merge gates.
   
   #44338 touches separate read/permalink schema fields; its implementation is 
not included here.
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   
   API-only; no UI changes.
   
   Before: semantic view ID 1 could be looked up as table dataset ID 1.
   
   After, with an accessible semantic view and its actual published names:
   
   ```json
   {
     "request": {
       "view_id": 1,
       "config": {
         "chart_type": "xy",
         "kind": "line",
         "x": {"name": "metric_time"},
         "y": [{"name": "revenue", "saved_metric": true}]
       }
     }
   }
   ```
   
   The result carries `1__semantic_view`, never `1__table`. Both selectors 
reject; missing/denied views return `view_not_found`; ad-hoc aggregation 
returns `semantic_view_adhoc_not_supported`.
   
   ### TESTING INSTRUCTIONS
   
   Local verification at `3a07a9cf5deee69dd39a014d51f6e66dee187c39`:
   
   - **603 passed** across affected schema/resolver, compile, preview, 
chart-utils, generate/update/get-data, Explore-link and validation-pipeline 
unit suites. Existing dataset test cases were not edited.
   - Staged-file `pre-commit run` passed, including MyPy, Ruff and custom 
Superset pylint.
   - Independent cross-model authorization/write-path review completed; 
identified issues were corrected and re-reviewed at the exact committed tree.
   - Controls include colliding IDs, access-before-metadata, UUID rebind, no 
cache/write on denial or compile failure, semantic query-context identity, 
implicit aggregation and retained SQL/sort rejection.
   
   Manual integration (not executed in this local packet):
   
   1. Configure an accessible semantic provider/view; use its published metric 
and dimension names in the request above. Repeat using the view UUID.
   2. Test both/neither selectors, denied/nonexistent view, ad-hoc aggregate 
and colliding table/view numeric IDs.
   3. Verify Explore/permalink and preview query the semantic source and 
preserve named metrics.
   4. **After composing/merging #44169**, verify a DB-backed save, reload, 
semantic update and cross-family rebind. Confirm chart edit permissions still 
apply.
   
   No live-provider, browser, DB-backed semantic save or dependency-composition 
result is claimed. No package installs, frontend builds or Docker work were 
performed.
   
   ### ADDITIONAL INFORMATION
   
   - [x] Has associated issue: 
[SC-120959](https://app.shortcut.com/preset/story/120959)
   - [x] Required feature flags: existing semantic-layer enablement and 
configured provider
   - [ ] 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
   


-- 
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]

Reply via email to