Skip to content

fix(chart-creation): preselect the newly created dataset by ID and drop name-based preselection - #45854

Open
Vitor-Avila wants to merge 6 commits into
masterfrom
fix-create-chart-preselect-dataset-by-id
Open

Vitor-Avila wants to merge 6 commits into
masterfrom
fix-create-chart-preselect-dataset-by-id

Conversation

@Vitor-Avila

@Vitor-Avila Vitor-Avila commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

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 a 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>);
  • makes the Create Chart page preselect only from dataset_id, fetching it directly with GET /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;
  • removes name-based preselection (?dataset=<name>), which was never reliable for the reason above. UPDATING.md documents the change;
  • moves the "The dataset has been saved" toast into the add-dataset footer, right after the create succeeds. The Create Chart page no longer shows it, so a hand-built /chart/add?dataset_id=<id> link doesn't announce a save that didn't happen;
  • removes the exactMatch / datasetsOnly options of fetchDatasourceList, 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 foo exist in different schemas of the same database.

Before

Before this change, the page could preselect a pre-existing foo (here schema_a) instead of the one just created.

Before: Create Chart preselects a pre-existing foo in schema_a

After

After running Create dataset and create chart for a new foo in schema_f, that dataset is preselected and the saved toast is shown.

After: Create Chart preselects the newly created foo in schema_f, with the saved toast

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. Check that the "The dataset has been saved" toast appears and that the preselected dataset is the one just created (hover to see its database/schema).
  4. Open /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=foo no longer preselects anything.

Automated:

  • ChartCreation.test.tsx: dataset_id is fetched via GET /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=42 and the saved toast fires.
  • fetchDatasourceList.test.ts: fetchDatasetById request shape.
  • npx jest src/pages/ChartCreation src/features/datasets src/views: 183/183 pass.

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • 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 (the ?dataset=<name> parameter of /chart/add; see UPDATING.md)

🤖 Generated with Claude Code

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>
@netlify

netlify Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for superset-docs-preview ready!

Name Link
🔨 Latest commit 1c69933
🔍 Latest deploy log https://app.netlify.com/projects/superset-docs-preview/deploys/6ae39eff8d72e7c0301255fb
😎 Deploy Preview https://deploy-preview-45854--superset-docs-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@codecov

codecov Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 84.70%. Comparing base (a8c13c6) to head (5d8731d).

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     
Flag Coverage Δ
javascript 80.95% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

…, 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>
@Vitor-Avila Vitor-Avila changed the title fix(chart-creation): preselect the newly created dataset by ID, not by name fix(chart-creation): preselect the newly created dataset by ID and drop name-based preselection Oct 29, 2026
@Vitor-Avila
Vitor-Avila marked this pull request as ready for review October 29, 2026 20:30
@Vitor-Avila
Vitor-Avila requested a balanced review from Copilot October 29, 2026 20:30

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 / datasetsOnly options from fetchDatasourceList and document the breaking URL param change in UPDATING.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

Comment thread superset-frontend/src/pages/ChartCreation/index.tsx
Comment thread superset-frontend/src/features/datasets/fetchDatasourceList.ts
Comment thread superset-frontend/src/pages/ChartCreation/index.tsx Outdated
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>
@Vitor-Avila
Vitor-Avila requested review from rebenitez1802 and sadpandajoe and removed request for sadpandajoe October 29, 2026 21:51
@codeant-ai-for-open-source

Copy link
Copy Markdown
Contributor

CodeAnt  CodeAnt PR Risk

🟢  Low Risk

  • The PR appears safe to merge; no actionable issues were identified in the review.

Assessed commit: 5d8731dcfa0a

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants