aminghadersohi opened a new pull request, #44684: URL: https://github.com/apache/superset/pull/44684
### SUMMARY The MCP chart preview built its Vega-Lite y encoding from the first column whose name looked like an aggregate or whose value looked numeric. Because Python `bool` is a subclass of `int`, a boolean x-axis column could be picked as the y field, and in general the y field was not guaranteed to be one of the chart's metrics. This change resolves the y field from the chart's `metrics` in form_data, using their result labels (same rules as `metric_result_label`) and picking the first one present in the result columns. The previous heuristic is kept only as a fallback when no metric label matches, and it no longer treats boolean values as numeric. ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF N/A (backend preview spec change) ### TESTING INSTRUCTIONS ``` pytest tests/unit_tests/mcp_service/chart/test_preview_utils.py ``` New tests cover: boolean x column with a numeric metric (y is the metric), multiple metrics (first matching metric is used), metrics with no matching label (fallback skips booleans), and no metrics (no y encoding, unchanged). ### ADDITIONAL INFORMATION - [ ] Has associated issue: - [ ] 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) -- 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]
