Repository navigation
Conversation
The examples importer bound each chart to its dataset by updating only the datasource_id, datasource_type and datasource_name columns. The datasource reference kept in the chart's params (and in its query_context, when present) kept the id from the instance the fixture was exported from, so after load-examples a chart's params could name a different dataset than the chart row. Explore hides this because Slice.form_data takes the datasource from the row, but code that reads params directly queried the wrong dataset. The importer now uses update_chart_config_dataset, as the chart, dashboard and assets importers already do.
Import a database, dataset and chart through the examples importer against the in-memory session and check that the chart's datasource_id and params follow the imported dataset instead of the stale id in the exported params. Drop the equivalent assertions from the mocked wiring test.
CodeAnt PR Risk: Low Risk
Assessed commit: |
Name the stale id in the chart params as a constant that no import into a fresh database can assign, instead of 21, and drop the guard assertion that the new id differs from it.
aminghadersohi
left a comment
There was a problem hiding this comment.
Verified against master. The examples importer only did config.update(dataset_info[...]), so params["datasource"] kept the exported id (21__table) while the datasource_id column was rebound. update_chart_config_dataset also rewrites params["datasource"] and the query_context datasource, form_data and per-query references, and it is the same helper the chart importer (commands/chart/importers/v1/__init__.py), dashboard importer and assets importer already use. The examples importer was the only one missing it. The test imports a chart with a stale id in params and asserts both datasource_id and params["datasource"] point at the imported dataset.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #45378 +/- ##
=======================================
Coverage 83.49% 83.49%
=======================================
Files 3047 3047
Lines 199516 199523 +7
Branches 46552 46554 +2
=======================================
+ Hits 166589 166597 +8
+ Misses 29701 29699 -2
- Partials 3226 3227 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
(cherry picked from commit 19bb094)
SUMMARY
The examples importer only updated the
datasource_id,datasource_typeanddatasource_namecolumns when binding a chart to its dataset, so the stale dataset id kept in the exported chartparams(e.g.21__tableinTotal_Revenue.yaml) survivedload-examples. Explore hides this becauseSlice.form_datatakes the datasource from the row, but code that readsparamsdirectly queries the wrong dataset.This makes the examples importer use
update_chart_config_datasetto rewrite those references, as the chart, dashboard and assets importers already do.BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
N/A
TESTING INSTRUCTIONS
Run
pytest tests/unit_tests/commands/importers/v1/examples_test.py.test_import_rewrites_stale_chart_datasource_referenceimports a chart with a stale dataset id in itsparamsand asserts it is rewritten to the imported dataset; it fails without this change.ADDITIONAL INFORMATION