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

   ## Summary
   
   Adds a `time_grain` parameter to `XYChartConfig` that allows LLM clients to 
specify temporal granularity when creating time-series charts via the MCP 
service.
   
   **Changes:**
   - Added `time_grain` field to `XYChartConfig` schema with support for common 
granularities (second, minute, hour, day, week, month, quarter, year)
   - Updated `map_xy_config()` to include `time_grain_sqla` in form_data when 
specified
   - Added 6 unit tests for the new functionality
   
   ## Problem
   
   When creating time-series charts through the MCP generate_chart tool, charts 
with temporal x-axis columns would aggregate all data together instead of 
grouping by the desired time period. This made it impossible for LLM clients to 
create charts showing monthly/weekly/daily breakdowns.
   
   ## Solution
   
   Added an optional `time_grain` parameter that maps to Superset's 
`time_grain_sqla` form_data field, allowing proper temporal grouping.
   
   **Example usage:**
   ```python
   config = XYChartConfig(
       chart_type="xy",
       x=ColumnRef(name="order_date"),
       y=[ColumnRef(name="revenue", aggregate="SUM")],
       kind="bar",
       time_grain="P1M",  # Monthly breakdown
   )
   ```
   
   ## BEFORE/AFTER
   
   **BEFORE:** Time-series charts aggregated all data into a single point
   **AFTER:** Time-series charts can show data grouped by the specified time 
grain (day, week, month, etc.)
   
   ## TESTING INSTRUCTIONS
   
   1. Run the new unit tests:
   ```bash
   pytest tests/unit_tests/mcp_service/chart/test_chart_utils.py -v -k 
time_grain
   ```
   
   2. Test via MCP client by creating a chart with `time_grain` parameter
   
   ## ADDITIONAL INFORMATION
   
   - [ ] Has unit tests
   - [ ] No breaking changes
   
   🤖 Generated with [Claude Code](https://claude.ai/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]

Reply via email to