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(native-filters): ignore unset filter box time range #16854

Merged
merged 1 commit into from
Sep 27, 2021

Conversation

villebro
Copy link
Member

SUMMARY

When a dashboard has both a native time range filter AND a filter box with a date filter, the native time range filter won't apply to charts, even if the filter box is set to "No filter". This is due to the filter box taking precedence over the native filter without evaluating if it's set or not.

This PR changes this so that the filter box doesn't override the value of the native filter if its value is "No filter" (the constant NO_TIME_RANGE). This is done by checking that the filter box time range is set earlier in the code flow. This check was previously done when setting the filter indicator status - this logic and associated unit tests were removed as they're now handled upstream. However, if both are set, the filter box takes precedence as before. Unit tests are added to handle both cases.

Closes #16839

AFTER

After this change the native time range filter applies properly:
image

BEFORE

Currently the native time range filter doesn't apply to a chart if the dashboard has a filter box with a date filter (see the missing year >= 1971 in the query):
image

TESTING INSTRUCTIONS

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 Sep 27, 2021

Codecov Report

Merging #16854 (b98bf61) into master (f703c12) will decrease coverage by 0.18%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #16854      +/-   ##
==========================================
- Coverage   76.93%   76.75%   -0.19%     
==========================================
  Files        1021     1021              
  Lines       54708    54601     -107     
  Branches     7459     7459              
==========================================
- Hits        42092    41909     -183     
- Misses      12372    12448      +76     
  Partials      244      244              
Flag Coverage Δ
hive ?
mysql 81.84% <100.00%> (ø)
postgres 81.80% <100.00%> (-0.11%) ⬇️
python 81.93% <100.00%> (-0.34%) ⬇️
sqlite 81.52% <100.00%> (+0.03%) ⬆️

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

Impacted Files Coverage Δ
superset/utils/core.py 89.84% <100.00%> (-0.13%) ⬇️
superset/db_engines/hive.py 0.00% <0.00%> (-82.15%) ⬇️
superset/db_engine_specs/hive.py 69.80% <0.00%> (-16.87%) ⬇️
superset/models/filter_set.py 75.43% <0.00%> (-3.03%) ⬇️
superset/models/dashboard.py 72.76% <0.00%> (-2.34%) ⬇️
superset/views/database/mixins.py 81.03% <0.00%> (-1.73%) ⬇️
superset/db_engine_specs/presto.py 83.47% <0.00%> (-1.05%) ⬇️
superset/views/core.py 75.46% <0.00%> (-0.93%) ⬇️
superset/db_engine_specs/base.py 88.17% <0.00%> (-0.39%) ⬇️
superset/sqllab/command.py 82.06% <0.00%> (-0.39%) ⬇️
... and 14 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 f703c12...b98bf61. Read the comment docs.

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.

LGTM, Thanks for adding the test.

@villebro villebro merged commit 0f16177 into apache:master Sep 27, 2021
@villebro villebro deleted the villebro/overlapping-time-range branch September 27, 2021 15:08
@junlincc junlincc added dashboard:native-filters Related to the native filters of the Dashboard rush! Requires immediate attention labels Sep 27, 2021
opus-42 pushed a commit to opus-42/incubator-superset that referenced this pull request Nov 14, 2021
QAlexBall pushed a commit to QAlexBall/superset that referenced this pull request Dec 28, 2021
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 1.4.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 dashboard:native-filters Related to the native filters of the Dashboard preset-io rush! Requires immediate attention size/M 🚢 1.4.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[native filter] when filter applied, sometimes the query did not update
4 participants