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

   ### SUMMARY
   
   Follow-up to #41555, which stopped *new* writes of `metricSqlExpressions` 
into `extra_form_data`. However, charts saved before that fix still carry the 
bloated data in their `params` and `query_context` columns — for datasources 
with many metrics this can be hundreds of MB per chart, loaded eagerly on every 
dashboard request.
   
   This migration strips `metricSqlExpressions` from `extra_form_data` in both 
columns for all `ag_grid_table` slices.
   
   **Root cause recap**: The AG Grid table plugin puts `metricSqlExpressions` 
(a `Record<string, string>` mapping every datasource metric/column to its SQL 
expression) into `ownState` on filter interactions. Before #41555, 
`ExploreViewContainer` spread all of `ownState` into `extra_form_data`, which 
was then serialised into `params` on save.
   
   **What this migration does**:
   - Queries all slices with `viz_type = 'ag_grid_table'`
   - Removes `metricSqlExpressions` from `params.extra_form_data`
   - Removes `metricSqlExpressions` from 
`query_context.form_data.extra_form_data`
   - Commits in a single transaction
   
   **Downgrade**: no-op — the field is runtime-derived by `transformProps` on 
each render and does not need to be restored.
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   
   N/A — data migration only.
   
   ### TESTING INSTRUCTIONS
   
   1. Find an `ag_grid_table` slice that was saved with filters applied before 
#41555 (or manually insert `metricSqlExpressions` into `params.extra_form_data` 
to simulate)
   2. Run `superset db upgrade`
   3. Confirm `metricSqlExpressions` is absent from `params` for all 
`ag_grid_table` slices
   4. Confirm charts still load and filter correctly (the field is regenerated 
at runtime)
   5. Run `superset db downgrade` — migration is a no-op and succeeds cleanly
   
   ### ADDITIONAL INFORMATION
   
   - [x] Has associated issue: closes #41555 (follow-up)
   - [ ] Required feature flags:
   - [ ] Changes UI
   - [x] Includes DB Migration (follow approval process in 
[SIP-59](https://github.com/apache/superset/issues/13351))
     - [x] 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
   
   **Runtime estimate**: O(n) over `ag_grid_table` slices. Reads and rewrites 
`params`/`query_context` in Python — for a typical installation with tens to 
hundreds of such slices this completes in seconds. For very large installations 
(thousands of slices) consider running during a maintenance window.
   
   🤖 Generated with [Claude Code](https://claude.com/claude-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