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

   ### SUMMARY
   
   Fixes SC-120965 (links SC-120341): `get_chart_sql` on a semantic-view chart 
returned `SemanticView.get_query_str`'s placeholder — `"Not implemented for 
semantic layers"` — **as the `sql` field with `error=null`**, presenting a fake 
SQL string as a success.
   
   A semantic view compiles its own query; there is no chart SQL to render. 
This gates the case up front and returns a structured marker instead:
   
   - Saved chart with `datasource_type == "semantic_view"`, or an unsaved chart 
whose resolved form-data datasource type is `"semantic_view"` → return 
`ChartError(error_type="Unsupported")` with `"SQL is not available for 
semantic-layer charts; the query is compiled by the semantic layer."`, **before 
any query context is built**.
   - The gate sits after the existing guest denial and chart lookup, and before 
`validate_chart_dataset` (which is `SqlaTable`/`DatasetDAO`-oriented and 
misreports for a view). It exposes nothing sensitive — a semantic view has no 
SQL, and `get_chart_info` already reports `datasource_type`.
   - Table/dataset charts are completely unchanged.
   
   Independent of open PR **#44206** (SC-104912), which removes the placeholder 
at the source (`get_query_str` raises `QueryObjectValidationError`): this 
tool-level gate short-circuits before the query string is ever consulted, so 
`get_chart_sql` is correct with or without #44206.
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   
   N/A — MCP tool behavior. Before: `sql="Not implemented for semantic 
layers"`, `error=null`. After: `ChartError(error_type="Unsupported")`, no `sql`.
   
   ### TESTING INSTRUCTIONS
   
   Unit (MCP tests require `fastmcp`; run where installed, e.g. the dev 
container):
   
   ```bash
   pytest tests/unit_tests/mcp_service/chart/tool/test_get_chart_sql.py -q   # 
79 passed
   ```
   
   New cases: saved semantic-view chart → `Unsupported` (exact message), and 
`validate_chart_dataset` / saved-context / form-data builders are **not** 
called (no query context built); unsaved semantic-view chart via 
`form_data_key` → same `Unsupported`, builders not called; table charts → 
unchanged path.
   
   **Live call against a MetricFlow-backed semantic-view chart is pending the 
demo core re-pin.** The gate is provider-independent (it keys off 
`datasource_type`, no `cube-local` needed), but no semantic-view *chart* exists 
outside the harness — superset-2's own stack can't create one (lacks the 
`cube-local` provider), and the harness runs core `89964b2a` (before this fix). 
End-to-end live verification is QA case **C5** in 
`superset-spec/semantic_layers/mcp-semantic-view-matrix-results.md`, to be 
exercised on the harness once this lands in the re-pin.
   
   ### ADDITIONAL INFORMATION
   
   - [x] Has associated issue: SC-120965 (links SC-120341)
   - [ ] Required feature flags:
   - [ ] Changes UI
   - [ ] Includes DB Migration
   - [ ] Introduces new feature or API
   - [ ] Removes existing feature or API
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   
   https://claude.ai/code/session_01C7U5oFfrqUyM6hJTZiW2uf
   


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