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

   ### SUMMARY
   
   `map_table_config` in 
[chart_utils.py](superset/mcp_service/chart/chart_utils.py) currently passes 
`config.sort_by` (a list of bare column-name strings) straight through to the 
saved `form_data["order_by_cols"]`. The frontend 
(`packages/superset-ui-core/src/query/extract/extractQueryFields.ts`) expects 
each entry in `order_by_cols` to be a JSON-serialized `[column, ascending]` 
tuple and calls `JSON.parse()` on each item — bare strings cause a 
`SyntaxError` and the chart fails to render.
   
   This PR JSON-serializes each sort column as `[col, false]` (descending), 
which is the natural default for sort-by-metric — the most common use case for 
table/AG-grid charts (e.g. "top N products by revenue").
   
   ### BEFORE/AFTER
   
   ```python
   # config.sort_by = ["product", "revenue"]
   
   # before
   form_data["order_by_cols"] == ["product", "revenue"]
   # → frontend JSON.parse("product") raises SyntaxError
   
   # after
   form_data["order_by_cols"] == ['["product", false]', '["revenue", false]']
   # → frontend parses each entry as a [col, ascending] tuple
   ```
   
   ### TESTING INSTRUCTIONS
   
   ```bash
   pytest 
tests/unit_tests/mcp_service/chart/test_chart_utils.py::TestMapTableConfig::test_map_table_config_with_sort
 -v
   ```
   
   The existing `test_map_table_config_with_sort` assertion is updated to 
expect the new format.
   
   ### 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))
   - [ ] 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]

Reply via email to