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

   ### SUMMARY
   
   The fallback path in `get_chart_data` (when a chart has no saved 
`query_context`) only handled `big_number`, `big_number_total`, and `pop_kpi` 
for the singular `metric` field. Charts like `world_map`, `bubble`, 
`sunburst_v2`, `treemap_v2`, and `gauge_chart` use non-standard `form_data` 
fields and produced empty metrics+columns+groupby, triggering the cryptic 
"Empty query?" error from deep in the query stack.
   
   This expands the fallback extraction to handle more chart types properly:
   
   - **Singular metric types with groupby-like fields**: `world_map`, 
`treemap_v2`, `sunburst_v2`, `gauge_chart` -- these use `metric` (singular) and 
may use `entity`, `series`, or `columns` for dimensional breakdown
   - **Bubble charts**: extract `x`, `y`, `size` as separate metric fields, use 
`entity` and `series` for groupby
   - **Fallback to singular metric**: if `metrics` (plural) is empty, try 
`metric` (singular) for any chart type
   - **Fallback to `columns` field**: if `groupby` is empty, try `columns` as 
an alternative (used by table charts, etc.)
   - **Fallback to `entity`/`series`**: if groupby is still empty, try these 
fields as a last resort
   - **Safety net**: if after all extraction, metrics AND columns AND groupby 
are all empty, return a clear `MissingQueryContext` error explaining the chart 
needs to be re-saved, instead of the cryptic "Empty query?" error
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   
   N/A - backend-only change, no UI modifications.
   
   ### TESTING INSTRUCTIONS
   
   ```bash
   pytest tests/unit_tests/mcp_service/chart/tool/test_get_chart_data.py -x -v
   ```
   
   All 38 tests pass (up from 18 previously), including new test classes:
   - `TestWorldMapChartFallback` - world_map metric/entity/series extraction
   - `TestTreemapAndSunburstFallback` - treemap_v2/sunburst_v2 with columns 
field
   - `TestGaugeChartFallback` - gauge_chart with singular metric
   - `TestBubbleChartFallback` - bubble x/y/size metric extraction
   - `TestFallbackMetricExtraction` - fallback to singular metric and columns 
field
   - `TestSafetyNetEmptyQuery` - safety net for unrecognizable form_data
   
   ### 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


-- 
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