Repository navigation
fix(chart-creation): preselect the newly created dataset by ID and drop name-based preselection - #45854
fix(chart-creation): preselect the newly created dataset by ID and drop name-based preselection#45854Vitor-Avila wants to merge 6 commits into
Conversation
After creating a dataset from Datasets -> + Dataset and choosing to create a chart, the Create Chart page looked the dataset up by table name. Dataset names are only unique per database, catalog and schema, so a same-named dataset elsewhere could be preselected instead, silently building the chart on the wrong data. The redirect now carries the new dataset ID (dataset_id) and the Create Chart page resolves the dataset by ID. The legacy ?dataset=<name> link keeps working as a fallback. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
✅ Deploy Preview for superset-docs-preview ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #45854 +/- ##
===========================================
+ Coverage 65.62% 84.70% +19.08%
===========================================
Files 3069 3069
Lines 205661 205597 -64
Branches 48336 48322 -14
===========================================
+ Hits 134956 174160 +39204
+ Misses 67624 28145 -39479
- Partials 3081 3292 +211
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:
|
…, fetch by ID Remove name-based preselection from /chart/add; only ?dataset_id=<id> is supported and the dataset is fetched via GET /api/v1/dataset/<id>. A missing or inaccessible dataset leaves the picker empty without a toast. The 'dataset has been saved' toast now fires from the add-dataset Footer after a successful create, so hand-built links no longer show it. Removes the unused exactMatch/datasetsOnly options of fetchDatasourceList. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…eselect-dataset-by-id
There was a problem hiding this comment.
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Copilot review overview
3 open issues
What changed in this PR
Updates chart creation flow to reliably preselect the newly created dataset by using its numeric ID instead of a non-unique name lookup, and relocates the “dataset saved” toast to the dataset creation flow.
Changes:
- Redirect from dataset creation to
/chart/add/?dataset_id=<id>and remove name-based preselection (?dataset=<name>). - Preload the dataset on Chart Creation via
GET /api/v1/dataset/<id>(with column selection) and handle missing/inaccessible IDs by leaving the picker empty. - Remove
exactMatch/datasetsOnlyoptions fromfetchDatasourceListand document the breaking URL param change inUPDATING.md.
| File | Description |
|---|---|
| superset-frontend/src/pages/ChartCreation/index.tsx | Switches preselection logic from name-based lookup to dataset ID fetch; removes toast from page load. |
| superset-frontend/src/pages/ChartCreation/ChartCreation.test.tsx | Updates/extends tests to cover dataset_id preselection, error cases, and no-toast behavior. |
| superset-frontend/src/features/datasets/fetchDatasourceList.ts | Simplifies datasource list fetch options and adds fetchDatasetById. |
| superset-frontend/src/features/datasets/fetchDatasourceList.test.ts | Adds coverage for the new fetchDatasetById request shape and error behavior. |
| superset-frontend/src/features/datasets/AddDataset/Footer/index.tsx | Redirects by newly created dataset ID and shows the “saved” toast on successful create. |
| superset-frontend/src/features/datasets/AddDataset/Footer/Footer.test.tsx | Verifies redirect by ID and toast emission prior to navigation. |
| UPDATING.md | Documents removal of ?dataset=<name> preselection support. |
Review effort: Lite
An empty dataset_id query parameter left the Create Chart page in a permanent loading state; derive the initial loading state from a non-empty value instead. Also encode the dataset ID as a single path segment when fetching it, and rename the flag to reflect what it checks. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>



SUMMARY
When you create a dataset from Datasets → + Dataset and click Create dataset and create chart, the Create Chart page is supposed to preselect the dataset you just created. The add-dataset footer already receives the new dataset's ID from the create call, but it threw the ID away and redirected to
/chart/add/?dataset=<table_name>. The Create Chart page then resolved that name with atable_namelookup limited to one result and ordered only bytable_name.Dataset names are only unique per database, catalog and schema. When another dataset with the same table name exists in a different schema, catalog or database, the lookup returns whichever row the database happens to put first. That is often the older dataset, so the user can unknowingly build a chart on the wrong data.
This change:
/chart/add/?dataset_id=<id>);dataset_id, fetching it directly withGET /api/v1/dataset/<id>and a column selection (the same fields the dataset picker already uses). A missing or inaccessible ID leaves the picker empty;?dataset=<name>), which was never reliable for the reason above.UPDATING.mddocuments the change;/chart/add?dataset_id=<id>link doesn't announce a save that didn't happen;exactMatch/datasetsOnlyoptions offetchDatasourceList, which existed only for the name lookup.SQL Lab's "Save dataset → Save & Explore" and saving a chart from a SQL Lab query already redirect by ID and are not affected.
BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
Several datasets named
fooexist in different schemas of the same database.Before
Before this change, the page could preselect a pre-existing
foo(hereschema_a) instead of the one just created.After
After running Create dataset and create chart for a new
fooinschema_f, that dataset is preselected and the saved toast is shown.TESTING INSTRUCTIONS
fooin one schema (for exampleschema_a).fooin another schema or database, and click Create dataset and create chart./chart/add/?dataset_id=<id>by hand: that dataset is preselected and no toast appears./chart/add/?dataset_id=<unknown id>leaves the picker empty./chart/add/?dataset=foono longer preselects anything.Automated:
ChartCreation.test.tsx:dataset_idis fetched viaGET /api/v1/dataset/<id>with the column selection and preselected (with and without semantic layers); 404 and 500 responses leave the picker empty and stop the loading state; a?dataset=param triggers no request; the page shows no toast.Footer.test.tsx: after a successful create returning 42, the redirect is/chart/add/?dataset_id=42and the saved toast fires.fetchDatasourceList.test.ts:fetchDatasetByIdrequest shape.npx jest src/pages/ChartCreation src/features/datasets src/views: 183/183 pass.ADDITIONAL INFORMATION
?dataset=<name>parameter of/chart/add; seeUPDATING.md)🤖 Generated with Claude Code