Vitor-Avila opened a new pull request, #45854: URL: https://github.com/apache/superset/pull/45854
### 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 an exact `table_name` lookup limited to one result and ordered only by `table_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: - redirects with the created dataset's ID (`/chart/add/?dataset_id=<id>`); - resolves `dataset_id` on the Create Chart page with a new `fetchDatasetById` helper (dataset list endpoint, `id eq` filter, same `DATASET_LIST_COLUMNS` the picker already uses), giving `dataset_id` precedence over `dataset`; - keeps the legacy `?dataset=<name>` path working for existing links, and keeps the loading state and "The dataset has been saved" toast for both params. 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 Two datasets named `foo` exist (`schema_a` and `schema_c` on the same database); the `schema_c` one was just created. ## Before  ## After  ### TESTING INSTRUCTIONS 1. Create a dataset from a table named `foo` in one schema (for example `schema_a`). 2. Go to **Datasets → + Dataset**, pick a table also named `foo` in another schema or database, and click **Create dataset and create chart**. 3. On the Create Chart page, check that the preselected dataset is the one you just created (hover to see its database/schema), not the older `foo`. 4. Opening `/chart/add/?dataset=<name>` still preselects by name, as before. Automated: - `ChartCreation.test.tsx`: with two datasets named `foo` (ids 7 and 42), a name lookup returns 7 and an ID lookup returns 42. `?dataset_id=42` (alone or together with `?dataset=foo`) must preselect 42, and an unknown `dataset_id` preselects nothing. The first test fails on the base commit (the page preselected 7). - `Footer.test.tsx`: after a successful create returning 42, the redirect carries `dataset_id=42` and not the table name. - `npx jest src/pages/ChartCreation src/features/datasets`: 99/99 pass. ### ADDITIONAL INFORMATION - [ ] Has associated issue: - [ ] Required feature flags: - [x] 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 🤖 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]
