Skip to content

fix(datasets): preserve metric/column uuids on dataset export#42393

Draft
sadpandajoe wants to merge 2 commits into
masterfrom
fix-dataset-export-uuid-folders
Draft

fix(datasets): preserve metric/column uuids on dataset export#42393
sadpandajoe wants to merge 2 commits into
masterfrom
fix-dataset-export-uuid-folders

Conversation

@sadpandajoe

@sadpandajoe sadpandajoe commented Jul 24, 2026

Copy link
Copy Markdown
Member

SUMMARY

Fixes metric/column custom-folder configuration being lost on dataset import (sc-105008 / PPR-1263; customer: Ippen-digital).

Root cause: dataset folder leaf nodes reference metrics/columns by UUID, but ImportExportMixin.export_to_dict did not forward export_uuids to the recursive child export, and the import schemas did not accept uuid. So exported metrics/columns arrived without a uuid, the importer minted fresh ones via UUIDMixin, and the persisted folders JSON kept pointing at the old uuids, so the frontend re-homed the metrics to the default folder. This forwards export_uuids into the recursive child export and accepts uuid in ImportV1ColumnSchema/ImportV1MetricSchema, so folder references round-trip. A clone-safety guard drops an incoming child uuid that already exists globally (importing a copy under a new parent), reverting to fresh-uuid behavior for that clone and avoiding the unique-constraint conflict. No DB migration; uuid already exists via UUIDMixin and is only emitted when export_uuids=True.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

Not applicable: backend export/import serialization change, no UI surface. Covered by an end-to-end export→import round-trip regression test asserting folder membership is retained, plus a clone-collision test.

TESTING INSTRUCTIONS

  1. Edit a dataset, create a custom folder, and move a metric into it; save.
  2. Export the dataset, then import the zip into another workspace.
  3. The custom folder and its metric membership are retained (previously the metric fell back to the default Metrics folder).

Tests: tests/unit_tests/datasets/commands/importers/v1/import_test.py (round-trip + clone collision), updated export_test.py and datasets/commands_tests.py.

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
  • Introduces new feature or API
  • Removes existing feature or API

Dataset folders reference metrics and columns by UUID. On export the
recursive child serialization in ImportExportMixin.export_to_dict did not
forward export_uuids, so exported metrics/columns carried no uuid. On
import each child was recreated with a fresh random uuid while the folders
JSON still pointed at the originals, so the item could no longer be matched
to its custom folder and was re-homed to the default folder.

Forward export_uuids into the recursive child export and accept uuid in the
import column/metric schemas so the references round-trip intact. The
import layer already recreates children with a provided uuid. Only the two
dataset export paths (dataset and database exports) pass export_uuids=True,
so behavior is unchanged for callers using the default.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@netlify

netlify Bot commented Jul 24, 2026

Copy link
Copy Markdown

Deploy Preview for superset-docs-preview ready!

Name Link
🔨 Latest commit 602bd65
🔍 Latest deploy log https://app.netlify.com/projects/superset-docs-preview/deploys/6a639f681fd48c00083c47fc
😎 Deploy Preview https://deploy-preview-42393--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 Jul 24, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 50.00000% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 65.21%. Comparing base (206fe7a) to head (c3adea9).
⚠️ Report is 37 commits behind head on master.

Files with missing lines Patch % Lines
superset/models/helpers.py 0.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #42393      +/-   ##
==========================================
- Coverage   65.25%   65.21%   -0.04%     
==========================================
  Files        2794     2795       +1     
  Lines      157396   157549     +153     
  Branches    35982    36007      +25     
==========================================
+ Hits       102706   102751      +45     
- Misses      52713    52820     +107     
- Partials     1977     1978       +1     
Flag Coverage Δ
hive 38.39% <50.00%> (-0.04%) ⬇️
mysql 57.57% <50.00%> (-0.06%) ⬇️
postgres 57.61% <50.00%> (-0.06%) ⬇️
presto 40.31% <50.00%> (-0.04%) ⬇️
python 59.02% <50.00%> (-0.06%) ⬇️
sqlite 57.24% <50.00%> (-0.06%) ⬇️
unit 100.00% <ø> (ø)

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.

Address review feedback on the metric/column uuid export fix:

- helpers.py: when importing a dataset config as a NEW dataset (edited
  dataset uuid) while the original still exists, an unchanged child uuid
  would be treated as new and violate the globally-unique constraint on
  table_columns/sql_metrics. Drop the incoming uuid for a new child whose
  uuid already exists so UUIDMixin assigns a fresh one, restoring the
  pre-change clone-via-YAML behavior.
- import_test.py: give the round-trip folder leaves their semantic type
  and assert the full imported folder structure; add a regression test for
  the clone path.
- commands_tests.py: reword a time-anchored comment.
- UPDATING.md: note that exports now include child uuid fields and fail
  schema validation on older releases (mixed-version fleets).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.

1 participant