AmoghAtreya opened a new pull request, #43176:
URL: https://github.com/apache/superset/pull/43176
### SUMMARY
Follow-up to #42822 / #43174. Chart execution could resolve
request-dependent Jinja (`filter_values`, `get_filters`, `url_param`,
`get_time_filter`, implicit `metric()` dataset lookup) while sibling MCP paths
(`get_chart_sql`, preview, compile, `query_dataset`, `get_table`) still
rendered fallbacks such as `No filter`, so displayed SQL could diverge from
executed SQL.
This extracts a shared helper that serializes a real
`QueryObject`/`QueryContext` onto `g.form_data` in the chart-data API shape,
and applies it immediately before every MCP `ChartDataCommand` construction.
`query_dataset` and `get_table` also copy `time_range` onto the query dict so
`get_time_filter()` sees the same value as SQL execution. Guest
`authorize_query` still runs first. Non-MCP `ChartDataCommand` sites are
unchanged.
### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
N/A
### TESTING INSTRUCTIONS
1. Create a virtual dataset whose SQL uses `{{ filter_values('region') }}`,
`{{ url_param('tenant') }}`, and `{{ get_time_filter().time_range }}`.
2. Build a chart on that dataset with a region filter, `url_params.tenant`,
and a time range.
3. Call `get_chart_data` and confirm the macros resolve (not `No filter` /
empty).
4. Call `get_chart_sql` and `get_chart_preview` on the same chart and
confirm the rendered SQL matches the executed query.
5. Repeat with an unsaved chart via `form_data_key`.
6. Call `query_dataset` / `get_table` with filters and `time_range` and
confirm `get_time_filter()` matches the request.
7. Confirm an embedded guest still cannot query a chart outside the guest
dashboard scope.
```bash
pytest -q \
tests/unit_tests/charts/data/form_data_test.py \
tests/unit_tests/mcp_service/chart/tool/test_get_chart_data.py \
tests/unit_tests/mcp_service/dataset/tool/test_query_dataset.py \
tests/unit_tests/mcp_service/chart/tool/test_get_chart_sql.py \
tests/unit_tests/mcp_service/chart/tool/test_get_chart_preview.py \
tests/unit_tests/mcp_service/chart/test_preview_utils.py \
tests/unit_tests/mcp_service/chart/test_compile.py \
tests/unit_tests/mcp_service/semantic_layer/tool/test_get_table.py \
tests/unit_tests/mcp_service/chart/tool/test_generate_chart.py
### ADDITIONAL INFORMATION
- [X] Has associated issue: Fixes #43174
- [ ] 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
--
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]