-
Notifications
You must be signed in to change notification settings - Fork 14.6k
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
[Adhoc Filters] integrating dashboard filters with adhoc filters #5056
[Adhoc Filters] integrating dashboard filters with adhoc filters #5056
Conversation
f5ed925
to
b3c92ff
Compare
Codecov Report
@@ Coverage Diff @@
## master #5056 +/- ##
==========================================
+ Coverage 77.52% 77.53% +<.01%
==========================================
Files 44 44
Lines 8707 8710 +3
==========================================
+ Hits 6750 6753 +3
Misses 1957 1957
Continue to review full report at Codecov.
|
superset/utils.py
Outdated
@@ -841,3 +841,39 @@ def ensure_path_exists(path): | |||
except OSError as exc: | |||
if not (os.path.isdir(path) and exc.errno == errno.EEXIST): | |||
raise | |||
|
|||
|
|||
def split_adhoc_filters_into_legacy_filters(fd): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a docstring here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Calling it "legacy" filters sounds a little to me like this is legacy code that will be cleaned up eventually, but this translation will be sticking around correct? I wonder if there's a word other than "legacy" that would describe this. I'm fine if not though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@michellethomas done!
b3c92ff
to
999f7a4
Compare
@@ -841,3 +841,45 @@ def ensure_path_exists(path): | |||
except OSError as exc: | |||
if not (os.path.isdir(path) and exc.errno == errno.EEXIST): | |||
raise | |||
|
|||
|
|||
def split_adhoc_filters_into_base_filters(fd): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typically we use the form_data
variable to represent form data. It's probably best to rename fd
to form_data
for consistency.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@john-bodley fd
is used throughout the codebase already
superset/views/core.py
Outdated
@@ -1279,6 +1279,7 @@ def explore(self, datasource_type=None, datasource_id=None): | |||
form_data['datasource'] = str(datasource_id) + '__' + datasource_type | |||
|
|||
# On explore, merge extra filters into the form data | |||
form_data = utils.split_adhoc_filters_into_base_filters(form_data) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your function mutates the form data so there's no need to re-assign. You can either make split_adhoc_filters_into_base_filters
create a copy and return the mutated copy or simply mutate the input which seems to be the pattern as per line #243.
superset/viz.py
Outdated
# extras are used to query elements specific to a datasource type | ||
# for instance the extra where clause that applies only to Tables | ||
|
||
form_data = utils.split_adhoc_filters_into_base_filters(form_data) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See ^^.
999f7a4
to
eadb9c5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@GabeLoins a couple of small nits, but otherwise LGTM.
# Add extra filters into the query form data | ||
# extras are used to query elements specific to a datasource type | ||
# for instance the extra where clause that applies only to Tables | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit. Remove blank line.
# for instance the extra where clause that applies only to Tables | ||
|
||
utils.split_adhoc_filters_into_base_filters(form_data) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit. Remove blank line.
(cherry picked from commit fa3e4e2)
This reverts commit fa3e4e2.
Thanks to @michellethomas for reporting. Filters on dashboards were not compatible with adhoc filters. This PR essentially factors out adhoc_filter => legacy filter conversion into a util function and then calls it both places
merge_extra_filters
is called.relevant issue: #5049
test plan:
reviewers:
@michellethomas @john-bodley @graceguo-supercat @williaster @mistercrunch