sadpandajoe opened a new pull request, #45250: URL: https://github.com/apache/superset/pull/45250
### SUMMARY When a chart has no saved query_context, get_chart_data falls back to building a generic query from form_data, which skips the frontend's buildQuery logic — time grain, trend line, period comparison. A big_number chart with time_grain_sqla: P3M, compare_lag: 1, show_trend_line: true returns the plain metric sum instead of the QoQ change the dashboard shows. The only existing signal was ctx.warning(...), an MCP log notification that never reaches the tool's structured result, so an LLM client presents the fallback number as exact. This threads that same message into the response's insights so the caveat travels with the data. Staleness of an *existing* saved query_context is deliberately not flagged. Explore writes params and query_context in the same request, but their form_data is never identical — buildV1ChartDataPayload adds force/result_format/result_type to the context's copy, and plugins such as MixedTimeseries (strips _b-suffixed keys) and Table (forces include_time: false in raw mode) rewrite form_data before the context is built. Comparing the two therefore flags every healthy chart, so a comparison-based check is worse than none; a real signal would need a persisted query_context timestamp. A regression test pins that an Explore-saved chart stays unflagged. MCP update_chart already clears query_context when params change, so the common drift path shows up as the missing-context case this PR covers. ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF N/A — MCP tool result only. ### TESTING INSTRUCTIONS 1. Create a chart through the REST API or MCP create_chart so it has params but no query_context (e.g. a big_number with compare_lag and show_trend_line). 2. Call the MCP get_chart_data tool for that chart. 3. The JSON result's insights now begins with "Chart has no saved query_context. Data may not match the chart visualization exactly. …". 4. Open and save the chart in Explore, call get_chart_data again — no such insight appears. 5. pytest tests/unit_tests/mcp_service/chart/tool/test_get_chart_data.py -k TestQueryContextAccuracyWarning ### ADDITIONAL INFORMATION - [x] Has associated issue: Fixes #45237 - [ ] Required feature flags: - [ ] Changes UI - [ ] Includes DB Migration - [ ] 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]
