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

   ### SUMMARY
   
   MCP chart configurations parse `time_grain` into a `TimeGrain` enum. Several 
mappers copied that object into `form_data.time_grain_sqla`; the query builder 
forwarded it to the Jinja context as `time_grain`. Jinja validates context 
values even for a saved metric such as `SUM(val)` with no template expressions, 
and rejects the enum's type.
   
   - Write the enum's string value at the form-data boundary for Big Number, 
XY, Mixed Timeseries, Sunburst, and Waterfall charts, including Sunburst update 
finalization. Interactive Pivot and Mixed Timeseries query B already use 
`.value`.
   - Route typed `ChartDataQueryValidationError` failures to `compile_error` 
before the database-engine fallback. Retain connection-error classification for 
database failures.
   - Document chart time grains and template/processing error responses.
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   
   Not a UI change.
   
   Before: a Big Number trendline with `time_grain="P1M"` and a plain saved 
metric raises `Unsafe template value for key time_grain: TimeGrain`. Template 
and processing validation failures can be reported as 
`database_connection_error`.
   
   After: the form data contains a primitive string, and typed query validation 
failures produce `compile_error` with the original details.
   
   ### TESTING INSTRUCTIONS
   
   The following regressions failed before the production changes on base 
commit `f0cfaff78811369431bd146f351782d91269707d` and pass with the changes:
   
   - `test_big_number_time_grain_renders_plain_saved_metric` in 
`tests/unit_tests/mcp_service/chart/test_time_grain_generic_axes.py`: exercises 
the real mapper, query builder, saved metric, and Jinja processor against a 
SQLite dataset.
   - `test_compile_chart_validation_failure_is_not_connection_error` in 
`tests/unit_tests/mcp_service/chart/test_compile.py`: both template and 
post-processing validation cases exercise the real `ChartDataCommand` error 
conversion.
   - `test_chart_time_grain_form_data_contains_strings` in 
`tests/unit_tests/mcp_service/chart/test_time_grain_generic_axes.py`: XY, Mixed 
Timeseries, Sunburst update, and Waterfall cases fail before the changes; the 
Interactive Pivot control passes on both versions.
   
   Targeted unit tests: **859 passed** (real-model tests excluded).
   
   ```bash
   PYTHONPATH="$PWD/superset-core/src:$PWD" pytest -q \
     tests/unit_tests/mcp_service/chart/test_time_grain_generic_axes.py \
     tests/unit_tests/mcp_service/chart/test_compile.py \
     tests/unit_tests/mcp_service/chart/test_big_number_chart.py \
     tests/unit_tests/mcp_service/chart/test_chart_utils.py \
     tests/unit_tests/mcp_service/chart/test_sunburst_chart.py \
     tests/unit_tests/mcp_service/chart/test_interactive_pivot_chart.py \
     tests/unit_tests/mcp_service/chart/test_waterfall_chart.py \
     tests/unit_tests/mcp_service/chart/test_new_chart_types.py \
     -m 'not manual and not llm_compliance'
   ```
   
   The compile suite includes wrapped and raw SQLAlchemy connection-error 
cases; both pass. Changed-file pre-commit hooks, including mypy, pass:
   
   ```bash
   pre-commit run --files \
     superset/mcp_service/chart/chart_utils.py \
     superset/mcp_service/chart/compile.py \
     tests/unit_tests/mcp_service/chart/test_compile.py \
     tests/unit_tests/mcp_service/chart/test_time_grain_generic_axes.py \
     docs/docs/using-superset/using-ai-with-superset.mdx
   ```
   
   For a manual check, use an accessible dataset with a temporal column and a 
saved aggregate metric. Generate a Big Number trendline with that column and 
`time_grain="P1M"`; inspect the preview and saved form data. Running-app 
verification was not performed because the local health endpoint was 
unavailable.
   
   ### ADDITIONAL INFORMATION
   
   - [ ] Has associated issue:
   - [ ] Required feature flags:
   - [ ] Changes UI
   - [ ] Includes DB Migration
     - [ ] 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