Skip to content

feat: add a command to import charts - #11743

Merged
betodealmeida merged 2 commits into
apache:masterfrom
betodealmeida:SO-1035
Nov 20, 2020
Merged

betodealmeida merged 2 commits into
apache:masterfrom
betodealmeida:SO-1035

Conversation

@betodealmeida

Copy link
Copy Markdown
Member

SUMMARY

This PR adds a new command ImportChartsCommand to import a new bundle with exported charts (#11167).

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

N/A

TEST PLAN

Added unit tests for imports and validation.

ADDITIONAL INFORMATION

Comment thread superset/models/helpers.py Outdated
Comment on lines 90 to 97

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This is not being used anywhere, seems like the result of a bad merge because we have an identical class method called parent_foreign_key_mappings (no leading underscore).

Comment thread superset/models/helpers.py Outdated

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This is necessary to preserve the parent ID in the config when importing, otherwise it gets deleted.

Comment thread tests/datasets/commands_tests.py Outdated

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This unit test is unrelated, but I thought about this case and decided to add it in this PR.

@codecov-io

codecov-io commented Nov 19, 2020 •

Copy link
Copy Markdown

Codecov Report

Merging #11743 (7998a5e) into master (8bdf943) will increase coverage by 0.58%.
The diff coverage is 94.23%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #11743      +/-   ##
==========================================
+ Coverage   66.61%   67.20%   +0.58%     
==========================================
  Files         897      899       +2     
  Lines       43463    43560      +97     
  Branches     4015     4015              
==========================================
+ Hits        28955    29276     +321     
+ Misses      14391    14180     -211     
+ Partials      117      104      -13     
Flag Coverage Δ
cypress 55.39% <ø> (+2.90%) ⬆️
javascript 62.82% <ø> (ø)
python 63.45% <94.23%> (+0.12%) ⬆️

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

Impacted Files Coverage Δ
superset/charts/commands/importers/v1/utils.py 93.33% <93.33%> (ø)
superset/charts/commands/importers/v1/__init__.py 93.82% <93.82%> (ø)
superset/charts/schemas.py 100.00% <100.00%> (ø)
superset/models/helpers.py 89.74% <100.00%> (+1.41%) ⬆️
superset/models/slice.py 85.47% <100.00%> (+0.08%) ⬆️
...rontend/src/visualizations/FilterBox/FilterBox.jsx 58.12% <0.00%> (-9.38%) ⬇️
.../src/dashboard/components/gridComponents/Chart.jsx 82.79% <0.00%> (-2.16%) ⬇️
superset-frontend/src/SqlLab/actions/sqlLab.js 64.52% <0.00%> (+0.21%) ⬆️
... and 34 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8bdf943...7998a5e. Read the comment docs.

@hughhhh hughhhh left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

👍

@betodealmeida
betodealmeida merged commit 2f4f877 into apache:master Nov 20, 2020
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 1.0.0 First shipped in 1.0.0 labels Mar 12, 2024
qfcwell pushed a commit to qfcwell/superset that referenced this pull request May 12, 2026
L4XB added a commit to L4XB/superset that referenced this pull request Sep 16, 2026
Deleting a dataset soft-deletes it, so the global visibility filter hides
the row from `Slice.table` while the chart itself survives. Exporting such
a chart then produced a bundle with neither `dataset_uuid` on the chart
YAML nor a `datasets/` file, and `ImportV1ChartSchema` — which has required
`dataset_uuid` since the chart importer was added in apache#11743 — rejected
Superset's own export with:

    {'dataset_uuid': ['Missing data for required field.']}

Dashboards hit the same error because `ExportDashboardsCommand` exports its
charts through `ExportChartsCommand`.

Resolve the chart's dataset through the DAO with the visibility filter
bypassed so a trashed dataset still reaches the bundle and the chart keeps
its only link to it. The DAO base filter still applies, so a dataset the
user cannot read stays unreachable. A chart whose dataset was hard-deleted
has no row to resolve and still exports without the field, as before.

Refs apache#44309

Deliberately not a closing keyword: this fixes the chart and dashboard half.
The dataset GENERIC_COMMAND_ERROR reported in the same issue did not
reproduce on master and is not addressed here, so the issue should stay
open until that half is understood.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels size/L 🚢 1.0.0 First shipped in 1.0.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants