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

   ### SUMMARY
   
   `get_chart_data` MCP tool was returning a `MissingQueryContext` error for
   Deck.gl charts (deck_scatter, deck_arc, deck_hex, etc.) when those charts had
   no saved `query_context`. Instead of offering a data retrieval path, the tool
   told users to re-open and re-save the chart in Superset.
   
   Deck.gl charts use spatial column configs (lat/lon pairs, geohash, delimited
   coordinates, GeoJSON) rather than the standard `metrics`/`groupby` structure.
   This PR teaches the form_data fallback path how to extract those columns.
   
   **Changes:**
   
   - Add `_deck_gl_spatial_cols` (private helper) and `resolve_deck_gl_columns`
     to `chart_helpers.py`. The helper reads `spatial`, `start_spatial`,
     `end_spatial`, `line_column`, `geojson`, `dimension`, and `js_columns`
     fields from `form_data` and returns the SQL column names needed by the
     underlying query — mirroring `BaseDeckGLViz.query_obj()` semantics.
   
   - Route `deck_*` viz types through the new helpers inside
     `build_query_dicts_from_form_data`. When a size/metric field is present
     (e.g., point-radius or weight metric), it is included in the query; spatial
     columns become the groupby dimensions. Without a metric, spatial columns
     become raw-select columns.
   
   - Remove the hard error block in `get_chart_data.py` that rejected all
     Deck.gl charts with `MissingQueryContext`. The existing safety-net (empty
     `columns` + empty `metrics`) still covers charts whose spatial config is
     completely missing.
   
   - Add unit tests covering: latlong, delimited, geohash spatial types;
     arc start/end spatial; `line_column`; `geojson`; `dimension`;
     `js_columns`; column deduplication; the `build_query_dicts_from_form_data`
     Deck.gl branch with and without metrics.
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   
   N/A (backend-only change to MCP tool data retrieval)
   
   ### TESTING INSTRUCTIONS
   
   1. Find or create a Deck.gl chart (e.g., Scatter, Arc, Hex) in Superset
      whose `params` JSON has a `spatial` field but **no** saved
      `query_context`.
   2. Call the `get_chart_data` MCP tool with that chart's ID.
   3. **Before**: `ChartError` with `error_type: "MissingQueryContext"` and a
      message asking the user to re-save the chart.
   4. **After**: The tool queries the underlying dataset using the lat/lon (or
      geohash/delimited) columns from `form_data` and returns tabular data.
   
   Run the new unit tests:
   ```bash
   pytest tests/unit_tests/mcp_service/chart/test_chart_helpers.py -x -q \
     -k "deck"
   ```
   
   ### ADDITIONAL INFORMATION
   
   - [ ] Has associated issue:
   - [ ] 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]

Reply via email to