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(chart): deprecate persisting url_params #18960

Merged
merged 4 commits into from
Mar 2, 2022

Conversation

villebro
Copy link
Member

@villebro villebro commented Feb 28, 2022

SUMMARY

Currently there are a few problems in Explore view:

  • if url_params are present in chart metadata, it's impossible to set new URL params to a chart in Explore view
  • When saving a chart, the following error toast is emitted: "Form data not found in cache, reverting to chart metadata.". See screenshot below:
    image

This PR changes how the hidden control url_params is handled by no longer be persisting it in chart metadata or cached chart form data. This is done by changing the following:

  • Remove the error message about form data missing from cache if form_data_key is not present in the URL (sort of unrelated, but a regression nonetheless).
  • Remove the url_params property from form_data if present before saving chart metadata
  • Adds the removed url_params back to the URL during saving in the frontend so that the reloaded Explore/Dashboard view will retain the URL params that were present before saving chart metadata
  • Adds an integration test for CreateChartCommand (bycatch - it was missing) and updates related unit tests

Note that charts that currently rely on default URL params that are persisted in chart data will still work like before - however, when the chart is saved/overwritten, the url_params state will be lost. So when making changes to old charts that are using the url_param function in templating code and haven't set default value as the second argument, users will need to update the url_param call to include the default value.

TESTING INSTRUCTIONS

  1. enable ENABLE_TEMPLATE_PROCESSING feature flag
  2. Crete a new chart using the flights dataset
  3. Add a groupby for AIRLINE, a metric for COUNT(*) and a filter for AIRLINE IN ('{{ url_param('test') }}')
  4. Add the param test=AA to the URL
  5. Save chart
  6. See error toast (no longer happens after PR)
  7. remove the URL param and reload the chart
  8. Notice that the URL param test=AA reappears (no longer happens after PR)

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

@codecov
Copy link

codecov bot commented Feb 28, 2022

Codecov Report

Merging #18960 (2d32d04) into master (7e336d1) will decrease coverage by 0.00%.
The diff coverage is 52.94%.

❗ Current head 2d32d04 differs from pull request most recent head 42805dd. Consider uploading reports for the commit 42805dd to get more accurate results

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #18960      +/-   ##
==========================================
- Coverage   66.40%   66.39%   -0.01%     
==========================================
  Files        1641     1641              
  Lines       63518    63522       +4     
  Branches     6422     6422              
==========================================
- Hits        42176    42174       -2     
- Misses      19681    19687       +6     
  Partials     1661     1661              
Flag Coverage Δ
hive 52.59% <16.66%> (-0.01%) ⬇️
mysql 81.83% <16.66%> (-0.01%) ⬇️
postgres 81.86% <16.66%> (-0.02%) ⬇️
presto 52.44% <16.66%> (-0.01%) ⬇️
python 82.30% <16.66%> (-0.02%) ⬇️
sqlite 81.57% <16.66%> (-0.01%) ⬇️

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

Impacted Files Coverage Δ
...perset-frontend/src/addSlice/AddSliceContainer.tsx 61.76% <ø> (ø)
superset/views/core.py 77.39% <0.00%> (-0.12%) ⬇️
...lugin-chart-echarts/src/Timeseries/transformers.ts 51.23% <33.33%> (ø)
...rset-frontend/src/explore/exploreUtils/formData.ts 83.33% <75.00%> (ø)
...board/components/nativeFilters/FilterBar/index.tsx 64.22% <100.00%> (+0.59%) ⬆️
...rset-frontend/src/explore/components/SaveModal.tsx 66.12% <100.00%> (ø)
superset/charts/commands/export.py 94.11% <100.00%> (ø)
superset/reports/commands/log_prune.py 85.71% <0.00%> (-3.58%) ⬇️
superset/commands/importers/v1/utils.py 89.13% <0.00%> (-2.18%) ⬇️
... and 3 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 7e336d1...42805dd. Read the comment docs.

@villebro villebro force-pushed the villebro/chart-url-params-depr branch from 611307d to 6fc5ef2 Compare February 28, 2022 13:43
@pull-request-size pull-request-size bot added size/L and removed size/M labels Feb 28, 2022
superset/charts/api.py Outdated Show resolved Hide resolved
superset/charts/api.py Outdated Show resolved Hide resolved
@villebro villebro force-pushed the villebro/chart-url-params-depr branch 3 times, most recently from 0687fc3 to 3654d25 Compare February 28, 2022 14:11
@villebro villebro changed the title fix(chart): deprecate peristing url_params [WIP] fix(chart): deprecate peristing url_params Feb 28, 2022
@villebro villebro force-pushed the villebro/chart-url-params-depr branch from 3654d25 to 7074744 Compare February 28, 2022 16:13
@villebro villebro force-pushed the villebro/chart-url-params-depr branch 2 times, most recently from 5367ef8 to 172a7b8 Compare March 1, 2022 07:48
@villebro villebro force-pushed the villebro/chart-url-params-depr branch from 172a7b8 to 74f8537 Compare March 1, 2022 08:05
@villebro villebro changed the title [WIP] fix(chart): deprecate peristing url_params fix(chart): deprecate peristing url_params Mar 1, 2022
@villebro villebro changed the title fix(chart): deprecate peristing url_params fix(chart): deprecate persisting url_params Mar 1, 2022
Copy link
Member

@michael-s-molina michael-s-molina left a comment

Choose a reason for hiding this comment

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

LGTM. Left a non-blocking suggestion.

@michael-s-molina
Copy link
Member

@zhaoyongjie Since you know this feature better, can you also review it and make sure I didn't forget anything?

Copy link
Member

@zhaoyongjie zhaoyongjie left a comment

Choose a reason for hiding this comment

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

Hey @villebro @michael-s-molina

Thanks for the fix. I tested all scenarios based on this PR, and it works fine!

  1. url_params was removed when I created a chart on the master branch and switch to the current PR.
  2. url_params was removed if I create a chart from the current branch.

But now the problem is, we can't find the original form_data_key anymore. This means that every time Chart is opened, a new form_data_key is generated. I would hear your thoughts.

@villebro villebro force-pushed the villebro/chart-url-params-depr branch from 4c54205 to c02543b Compare March 1, 2022 14:05
@villebro villebro merged commit bd63a1b into apache:master Mar 2, 2022
@villebro villebro deleted the villebro/chart-url-params-depr branch March 2, 2022 05:44
@sadpandajoe
Copy link
Contributor

🏷️ preset:2022.9

sadpandajoe pushed a commit to preset-io/superset that referenced this pull request Mar 2, 2022
* fix(chart): deprecate peristing url_params

* remove duplicated backend logic

* use omitBy

* simplify omit

(cherry picked from commit bd63a1b)
villebro added a commit that referenced this pull request Apr 3, 2022
* fix(chart): deprecate peristing url_params

* remove duplicated backend logic

* use omitBy

* simplify omit

(cherry picked from commit bd63a1b)
@mistercrunch mistercrunch added 🍒 1.5.0 🍒 1.5.1 🍒 1.5.2 🍒 1.5.3 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 2.0.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 preset:2022.9 preset-io size/L 🍒 1.5.0 🍒 1.5.1 🍒 1.5.2 🍒 1.5.3 🚢 2.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants