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

   ### SUMMARY
   `superset load-examples` bound each example chart to its dataset by updating 
only the `datasource_id`, `datasource_type` and `datasource_name` columns. The 
datasource reference stored inside the chart's `params` (and its 
`query_context`, when present) kept the id from the instance the fixture was 
exported from. For example `Total_Revenue.yaml` ships `datasource: 21__table`, 
so on an instance where `cleaned_sales_data` is dataset 13 the chart row 
pointed at dataset 13 while its `params` named dataset 21.
   
   Explore hides the mismatch because `Slice.form_data` takes the datasource 
from the row, but code that reads `params` directly queried the wrong dataset. 
On the 7.0 branch, `get_chart_preview` in the MCP service fails for such a 
chart with `Columns missing in dataset: ['sales']`, although the chart renders 
fine in the browser.
   
   The chart, dashboard and assets importers already call 
`update_chart_config_dataset`, which rewrites `params["datasource"]` and the 
saved `query_context` together with the columns. This PR makes the examples 
importer do the same. It adds no new id handling and does not change the export 
format. Numeric ids inside exported `params` (`datasource`, `slice_id`, 
`dashboards`) have no mapping value across instances; the uuid fields at the 
top level of the export (`dataset_uuid`, `uuid`, `database_uuid`) are what the 
importer resolves, and the importer overwrites the stale ids rather than 
trusting them.
   
   The existing `test_import_passes_ignore_permissions_to_all_importers` now 
gives the chart a stale `21__table` and asserts that `import_chart` receives 
the new dataset id both in `datasource_id` and in `params["datasource"]`. The 
assertion fails without the importer change.
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   N/A
   
   ### TESTING INSTRUCTIONS
   Run `pytest tests/unit_tests/commands/importers/v1/examples_test.py`.
   
   To check manually, run `superset load-examples` on an instance where the 
example datasets do not get the ids they had in the fixtures, then compare a 
chart row's `datasource_id` with the `datasource` key in its `params` (for 
example chart "Total Revenue" in the Sales Dashboard). They should agree.
   
   ### 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