Amen-Zelealem opened a new issue, #35221: URL: https://github.com/apache/superset/issues/35221
### Bug description ## 🐛 Bug Report ### **Summary** The Superset API does not support programmatically populating the METRIC field when creating charts, requiring manual drag-and-drop interaction even when metrics are properly defined in the chart payload. ### **Expected Behavior** When creating a chart via the API with a properly formatted metrics array in the `params` field, the METRIC field should be automatically populated in the Superset UI, eliminating the need for manual drag-and-drop configuration. ### **Actual Behavior** The METRIC field remains empty in the Superset UI even when the chart payload includes correctly formatted metrics. Users must manually drag metrics from the left panel to the METRIC field, which defeats the purpose of programmatic chart creation. ### **Steps to Reproduce** 1. **Create a dataset** via API: ```bash POST /api/v1/dataset/ { "database": 1, "table_name": "test_table", "schema": "public" } ``` 2. **Create a chart** with metrics in the payload: ```bash POST /api/v1/chart/ { "slice_name": "Test Chart", "viz_type": "pie", "datasource_id": 123, "datasource_type": "table", "params": "{\"groupby\": [\"status\"], \"metrics\": [\"COUNT(*)\"]}" } ``` 3. **Open the chart** in Superset UI 4. **Observe** that the METRIC field is empty despite `COUNT(*)` being available in the left panel ### **Environment** - **Superset Version**: Version: 4.1.2 - **Python Version**: 3.12 - **Database**: PostgreSQL - **Browser**: Chrome ### **Additional Context** #### **What Works:** ✅ Dataset creation via API ✅ Chart creation via API ✅ Dimension/groupby configuration ✅ Chart styling and customization ✅ All other chart properties #### **What Doesn't Work:** ❌ Automatic METRIC field population ❌ Programmatic metric configuration #### **Attempted Solutions:** 1. **Simple string format**: `["COUNT(*)"]` 2. **Object format**: `[{"label": "COUNT(*)", "expressionType": "SIMPLE", "sqlExpression": "COUNT(*)"}]` 3. **Extended object format**: `[{"label": "COUNT(*)", "expressionType": "SIMPLE", "sqlExpression": "COUNT(*)", "id": "COUNT(*)", "metric_name": "COUNT(*)"}]` 4. **Metric endpoints**: All `/metric/`, `/metrics/`, `/metric` endpoints return 404 5. **Immediate metric addition**: Tried adding metrics right after dataset creation #### **Impact:** This limitation significantly reduces the value of Superset's API for automated dashboard creation workflows. Users must manually configure metrics for every chart, making it impossible to fully automate dashboard generation. #### **Proposed Solution:** The API should accept and properly process metrics in the chart creation payload, automatically populating the METRIC field in the UI. This would enable true programmatic chart creation without manual intervention. --- **Note**: This issue affects the core functionality of programmatic chart creation and should be prioritized for the next release. ### Screenshots/recordings _No response_ ### Superset version master / latest-dev ### Python version 3.9 ### Node version 16 ### Browser Chrome ### Additional context _No response_ ### Checklist - [ ] I have searched Superset docs and Slack and didn't find a solution to my problem. - [ ] I have searched the GitHub issue tracker and didn't find a similar bug report. - [ ] I have checked Superset's logs for errors and if I found a relevant Python stacktrace, I included it here as text in the "additional context" section. -- 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: notifications-unsubscr...@superset.apache.org.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: notifications-unsubscr...@superset.apache.org For additional commands, e-mail: notifications-h...@superset.apache.org