superset icon indicating copy to clipboard operation
superset copied to clipboard

fix(dashboard): update cross filter scoping chart id references during dashboard import

Open chanduapple opened this issue 2 years ago • 11 comments

during the dashboard import, cross filter scoping is not retained because of not updating chart id references. this commit contains the necessary fix for the same.

this pull request provides the fix for the issue #19944 slack discussion: https://apache-superset.slack.com/archives/C015WAZL0KH/p1699248398108929

SUMMARY

updated the utils.py to update the chart id references for cross filter scoping also. currently chart id reference updates is present for native filters, position and few others, but not for cross filter scoping.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

  1. create dashboard with more than 2 charts and apply cross filter scoping. as shown below.
  2. export the dashboard.
  3. if you are importing in the same environment, then delete dashboard and charts.
  4. import the dashboard again.
  5. expectation is cross filter scoping should be retained.
  6. actual is cross filter scoping has been removed and global cross filter scoping changes to all charts. dashboard in env1 image

BEFORE FIX

dashboard after importing to env2 image

AFTER FIX

dashboard after importing to env2 image

TESTING INSTRUCTIONS

  1. create dashboard with cross filter scoping.
  2. export the dashboard.
  3. delete the dashboard and charts used in dashboards.
  4. import the dashboard
  5. check the cross filter scoping

ADDITIONAL INFORMATION

Fixes "#19944"

  • [x] Has associated issue: #19944
  • [ ] 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

chanduapple avatar Dec 11 '23 18:12 chanduapple

@john-bodley @michael-s-molina @villebro could you please review this PR. This is kind of blocker to use import/export feature for dashboard, since people need to make the changes manually after importing dashboard as cross filter scoping was not retained. i am contributing first time, please let me know if any changes required or to furnish more info.

chanduapple avatar Dec 11 '23 18:12 chanduapple

@betodealmeida do you think it would make sense to start phasing both the pseudo-ids that are used on the frontend, and the serial ids used on the backend, and replace them all with their respective uuid representations? This way we wouldn't have to do all this complicated remapping during import/export..

villebro avatar Dec 11 '23 18:12 villebro

@john-bodley @michael-s-molina @villebro could you please review this PR. This is kind of blocker to use import/export feature for dashboard, since people need to make the changes manually after importing dashboard as cross filter scoping was not retained. i am contributing first time, please let me know if any changes required or to furnish more info.

@chanduapple thanks for the contribution, and I agree with the changes done here. I'll let CI complete before reviewing the code. Also, I'm not sure if our current test suites have tests for similar re-mappings (the native filters may have one), but if it's possible, it would be great if you could add a test to cover this particular fix.

villebro avatar Dec 11 '23 18:12 villebro

@villebro is there any guideline/info about adding tests, like how to add test and run, I will go through once, I have tested manually.

chanduapple avatar Dec 11 '23 18:12 chanduapple

@chanduapple the CONTRIBUTING.md has some directives for running the test suites: https://github.com/apache/superset/blob/master/CONTRIBUTING.md#testing The relevant tests I think you're interested in are in https://github.com/apache/superset/blob/master/tests/integration_tests/import_export_tests.py.

villebro avatar Dec 11 '23 18:12 villebro

@villebro i have fixed below earlier CI workflow issues.

  1. pull request title has been modified.
  2. removed trailing white spaces.
  3. List error
  4. R0912: Too many branches (18/15) (too-many-branches)

Could you please approve the workflow to be rerun and review the code changes?

@betodealmeida @john-bodley

chanduapple avatar Jan 01 '24 16:01 chanduapple

Codecov Report

Attention: Patch coverage is 47.05882% with 9 lines in your changes missing coverage. Please review.

Project coverage is 69.16%. Comparing base (3daa038) to head (02b2066). Report is 1392 commits behind head on master.

Files Patch % Lines
superset/commands/dashboard/importers/v1/utils.py 47.05% 9 Missing :warning:
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #26239      +/-   ##
==========================================
+ Coverage   66.97%   69.16%   +2.18%     
==========================================
  Files        1948     1948              
  Lines       76061    76078      +17     
  Branches     8493     8493              
==========================================
+ Hits        50943    52616    +1673     
+ Misses      22938    21282    -1656     
  Partials     2180     2180              
Flag Coverage Δ
hive 53.66% <5.88%> (?)
mysql 78.05% <47.05%> (-0.02%) :arrow_down:
postgres 78.15% <47.05%> (-0.02%) :arrow_down:
presto 53.61% <5.88%> (?)
python 82.84% <47.05%> (+4.53%) :arrow_up:
sqlite 77.74% <47.05%> (-0.02%) :arrow_down:
unit 55.87% <47.05%> (?)

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

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar Jan 10 '24 18:01 codecov[bot]

@villebro @betodealmeida could you please review and approve, let me know if any thing to be modified. please help me out here.

chanduapple avatar Jan 12 '24 06:01 chanduapple

Looks like this one needs the pre-commit hooks run. Hope we can get it through and close out the old issue!

rusackas avatar Apr 23 '24 23:04 rusackas

Any updates on this folks? We are blocked by this issue to export->import charts with cross-filter scoping.

ferschubert avatar Aug 21 '24 18:08 ferschubert