Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: column extra in import/export #17738

Merged
merged 1 commit into from
Dec 15, 2021
Merged

Conversation

betodealmeida
Copy link
Member

@betodealmeida betodealmeida commented Dec 14, 2021

SUMMARY

When exporting a dataset, the extra attribute in columns was being exported as a plain string, instead of parsing the JSON. This would result in YAML like this:

- column_name: city
  ...
  extra: '{"foo": "bar"}'

Instead of:

- column_name: city
  ...
  extra:
    foo: bar

This PR:

  1. Fixes the export, so that we get the more readable format.
  2. Fixes the import, so that both formats are accepted.

(I also noted that the dataset extra attribute is not being parsed from JSON, and both import/export assume it's a string. I'll improve it in a next PR, exporting as an object and importing both formats.)

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

N/A

TESTING INSTRUCTIONS

Added unit tests, testing that export is correct and import supports both formats.

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

try:
table_exists = example_database.has_table_by_name(dataset.table_name)
Copy link
Member Author

Choose a reason for hiding this comment

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

This logic was wrong, but since it's only used when loading examples (where the dataset DB is the examples DB) it works fine.

@codecov
Copy link

codecov bot commented Dec 14, 2021

Codecov Report

Merging #17738 (1a01826) into master (0d2299c) will increase coverage by 0.01%.
The diff coverage is 60.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #17738      +/-   ##
==========================================
+ Coverage   68.06%   68.07%   +0.01%     
==========================================
  Files        1653     1653              
  Lines       66374    66374              
  Branches     7121     7121              
==========================================
+ Hits        45177    45185       +8     
+ Misses      19300    19292       -8     
  Partials     1897     1897              
Flag Coverage Δ
hive 81.79% <60.00%> (+0.01%) ⬆️
mysql 82.16% <60.00%> (+0.01%) ⬆️
postgres 82.22% <60.00%> (+0.02%) ⬆️
python 82.56% <60.00%> (+0.02%) ⬆️
sqlite 81.90% <60.00%> (+0.01%) ⬆️

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

Impacted Files Coverage Δ
superset/datasets/commands/importers/v1/utils.py 58.33% <50.00%> (-0.50%) ⬇️
superset/datasets/commands/export.py 87.50% <71.42%> (+8.77%) ⬆️
superset/datasets/schemas.py 96.61% <100.00%> (ø)
superset/dashboards/commands/importers/v1/utils.py 81.42% <0.00%> (ø)
superset/reports/commands/execute.py 91.22% <0.00%> (+0.38%) ⬆️
superset/common/query_object.py 95.62% <0.00%> (+0.54%) ⬆️
superset/commands/importers/v1/utils.py 91.30% <0.00%> (+2.17%) ⬆️
superset/reports/commands/log_prune.py 89.28% <0.00%> (+3.57%) ⬆️

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 0d2299c...1a01826. Read the comment docs.

@betodealmeida betodealmeida merged commit 37cc2c4 into apache:master Dec 15, 2021
shcoderAlex pushed a commit to casual-precision/superset that referenced this pull request Feb 7, 2022
bwang221 pushed a commit to casual-precision/superset that referenced this pull request Feb 10, 2022
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 1.5.0 labels Mar 13, 2024
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 lts-v1 size/XL 🚢 1.5.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants